Mercurial > notdcc
comparison misc/start-grey.in @ 0:c7f6b056b673
First import of vendor version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Tue, 10 Mar 2009 13:49:58 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c7f6b056b673 |
---|---|
1 #! /bin/sh | |
2 | |
3 # start dccd for greylisting | |
4 # This script assumes that it is being run by root or the DCC user, probably | |
5 # while the system is starting. If start-dccm or start-dccifd, | |
6 # This script should be run before both of them to # avoid complaints. | |
7 # See the misc/rcDCC script. | |
8 | |
9 # Copyright (c) 2008 by Rhyolite Software, LLC | |
10 # | |
11 # This agreement is not applicable to any entity which sells anti-spam | |
12 # solutions to others or provides an anti-spam solution as part of a | |
13 # security solution sold to other entities, or to a private network | |
14 # which employs the DCC or uses data provided by operation of the DCC | |
15 # but does not provide corresponding data to other users. | |
16 # | |
17 # Permission to use, copy, modify, and distribute this software without | |
18 # changes for any purpose with or without fee is hereby granted, provided | |
19 # that the above copyright notice and this permission notice appear in all | |
20 # copies and any distributed versions or copies are either unchanged | |
21 # or not called anything similar to "DCC" or "Distributed Checksum | |
22 # Clearinghouse". | |
23 # | |
24 # Parties not eligible to receive a license under this agreement can | |
25 # obtain a commercial license to use DCC by contacting Rhyolite Software | |
26 # at sales@rhyolite.com. | |
27 # | |
28 # A commercial license would be for Distributed Checksum and Reputation | |
29 # Clearinghouse software. That software includes additional features. This | |
30 # free license for Distributed ChecksumClearinghouse Software does not in any | |
31 # way grant permision to use Distributed Checksum and Reputation Clearinghouse | |
32 # software | |
33 # | |
34 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL | |
35 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
36 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC | |
37 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES | |
38 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
39 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
40 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
41 # SOFTWARE. | |
42 # Rhyolite Software DCC 1.3.103-1.18 $Revision$ | |
43 # @configure_input@ | |
44 | |
45 exec 1>&2 </dev/null | |
46 | |
47 LOGGER_TAG=start-grey-dccd | |
48 DCC_LOGGER="@DCC_LOGGER@" | |
49 DCC_HOMEDIR=@prefix@ | |
50 VERBOSE= | |
51 DEBUG= | |
52 # check the args once to get the home directory | |
53 while getopts ":xvh:u:a:i:" c; do | |
54 case $c in | |
55 x) set -x; DEBUG=-x; VERBOSE=-v;; | |
56 v) VERBOSE=-v;; | |
57 h) CWD=`pwd` | |
58 DCC_HOMEDIR=`echo "$OPTARG" | sed -e "s@^[^/]@$CWD/&@"`;; | |
59 *) ;; | |
60 esac | |
61 done | |
62 if test ! -s $DCC_HOMEDIR/dcc_conf; then | |
63 eval $DCC_LOGGER "cannot find $DCC_HOMEDIR/dcc_conf" | |
64 fi | |
65 . $DCC_HOMEDIR/dcc_conf | |
66 # deal with bash reserved $UID | |
67 if test -z "$DCCUID" -a -n "$UID"; then | |
68 DCCUID="$UID" | |
69 fi | |
70 if test "$BRAND" != ""; then | |
71 BRAND="-n $BRAND" | |
72 fi | |
73 GREY_DCCD_ARGS="$GREY_DCCD_ARGS $BRAND $DCC_LOG_ARGS" | |
74 | |
75 STOP_ARGS= | |
76 USAGE="`basename $0`: [-xv] [-h homedir] [-u UID] [-a args] [-i id]" | |
77 OPTIND=1 | |
78 while getopts "xvh:u:a:i:" c; do | |
79 case $c in | |
80 x) ;; | |
81 v) ;; | |
82 h) ;; | |
83 u) DCCUID="$OPTARG";; | |
84 a) GREY_DCCD_ARGS="$GREY_DCCD_ARGS $OPTARG";; | |
85 i) $GREY_SRVR_ID="$OPTARG"; STOP_ARGS="$STOP_ARGS -i $GREY_SRVR_ID";; | |
86 *) eval $DCC_LOGGER "$USAGE"; exit 1;; | |
87 esac | |
88 done | |
89 shift `expr $OPTIND - 1 || true` | |
90 if test "$#" -ne 0; then | |
91 eval $DCC_LOGGER "$USAGE" | |
92 exit 1 | |
93 fi | |
94 | |
95 if test "$DCC_HOMEDIR" != @prefix@; then | |
96 GREY_DCCD_ARGS="-h $DCC_HOMEDIR $GREY_DCCD_ARGS" | |
97 STOP_ARGS="-h $DCC_HOMEDIR $STOP_ARGS" | |
98 fi | |
99 | |
100 | |
101 # stop the current daemon, including giving it time to shut down gracefully | |
102 $DCC_LIBEXEC/stop-dccd -G $DEBUG $VERBOSE $STOP_ARGS | |
103 | |
104 case X"$GREY_ENABLE" in | |
105 X[oO][nN]) | |
106 # start the greylist server | |
107 ;; | |
108 X) | |
109 # if $GREY_CLIENT_ARGS contains "-G" and $GREY_ENABLE is not set | |
110 # then start the greylist server | |
111 if test -z "$GREY_CLIENT_ARGS"; then | |
112 exit 0 | |
113 fi | |
114 ;; | |
115 *) exit 0;; | |
116 esac | |
117 | |
118 # tell dccd where to find dbclean if it is not where dccd was built to look. | |
119 if test "$DCC_LIBEXEC" != @libexecdir@; then | |
120 GREY_DCCD_ARGS="-C $DCC_LIBEXEC/dbclean $GREY_DCCD_ARGS" | |
121 fi | |
122 | |
123 if test ! -x $DCC_LIBEXEC/dccd; then | |
124 eval $DCC_LOGGER "cannot start greylist dcccd because dccd has not been installed" | |
125 exit 1 | |
126 fi | |
127 | |
128 if test -z "$GREY_SRVR_ID"; then | |
129 if test -n "`grep '# auto local greylist server-ID' $DCC_HOMEDIR/ids`" \ | |
130 -a -n "`grep '^32702' $DCC_HOMEDIR/ids`"; then | |
131 GREY_SRVR_ID=32702 | |
132 else | |
133 eval $DCC_LOGGER "'cannot start greylist dccd; GREY_SRVR_ID not set in $DCC_HOMEDIR/dcc_conf'" | |
134 exit 1 | |
135 fi | |
136 fi | |
137 GREY_DCCD_ARGS="-i $GREY_SRVR_ID $GREY_DCCD_ARGS" | |
138 | |
139 # first try to use `su -` to set limits | |
140 # fall back to -I for systems where su requires a valid shell in | |
141 # /etc/passwd but where the dcc user does not have one | |
142 if test -n "$DCCUID" -a X"$DCCUID" != X"$USER"; then | |
143 if @DCC_SU@ $DCCUID -c date >/dev/null 2>&1; then | |
144 @DCC_SU@ $DCCUID -c "$DCC_LIBEXEC/dccd -Gon $GREY_DCCD_ARGS" | |
145 exit | |
146 fi | |
147 GREY_DCCD_ARGS="-I,$DCCUID $GREY_DCCD_ARGS" | |
148 fi | |
149 eval $DCC_LIBEXEC/dccd -Gon $GREY_DCCD_ARGS |