Mercurial > notdcc
comparison misc/start-dccifd.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 dccifd | |
4 | |
5 # This script assumes that it is being run by root or the DCC user, probably | |
6 # while the system is starting. See the misc/rcDCC script. | |
7 | |
8 # Copyright (c) 2008 by Rhyolite Software, LLC | |
9 # | |
10 # This agreement is not applicable to any entity which sells anti-spam | |
11 # solutions to others or provides an anti-spam solution as part of a | |
12 # security solution sold to other entities, or to a private network | |
13 # which employs the DCC or uses data provided by operation of the DCC | |
14 # but does not provide corresponding data to other users. | |
15 # | |
16 # Permission to use, copy, modify, and distribute this software without | |
17 # changes for any purpose with or without fee is hereby granted, provided | |
18 # that the above copyright notice and this permission notice appear in all | |
19 # copies and any distributed versions or copies are either unchanged | |
20 # or not called anything similar to "DCC" or "Distributed Checksum | |
21 # Clearinghouse". | |
22 # | |
23 # Parties not eligible to receive a license under this agreement can | |
24 # obtain a commercial license to use DCC by contacting Rhyolite Software | |
25 # at sales@rhyolite.com. | |
26 # | |
27 # A commercial license would be for Distributed Checksum and Reputation | |
28 # Clearinghouse software. That software includes additional features. This | |
29 # free license for Distributed ChecksumClearinghouse Software does not in any | |
30 # way grant permision to use Distributed Checksum and Reputation Clearinghouse | |
31 # software | |
32 # | |
33 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL | |
34 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
35 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC | |
36 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES | |
37 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
38 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
39 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
40 # SOFTWARE. | |
41 # Rhyolite Software DCC 1.3.103-1.31 $Revision$ | |
42 # @configure_input@ | |
43 | |
44 exec 1>&2 </dev/null | |
45 | |
46 LOGGER_TAG=start-dccifd | |
47 DCC_LOGGER="@DCC_LOGGER@" | |
48 DCC_HOMEDIR=@prefix@ | |
49 QUIET=yes | |
50 AUTOSTART= | |
51 # check the args once to get the home directory | |
52 while getopts ":xvAh:r:a:" c; do | |
53 case $c in | |
54 x) set -x;; | |
55 v) QUIET=;; | |
56 A) AUTOSTART=y;; | |
57 h) DCC_HOMEDIR="$OPTARG";; | |
58 *) ;; | |
59 esac | |
60 done | |
61 if test ! -s $DCC_HOMEDIR/dcc_conf; then | |
62 eval $DCC_LOGGER "cannot find $DCC_HOMEDIR/dcc_conf" | |
63 fi | |
64 . $DCC_HOMEDIR/dcc_conf | |
65 | |
66 if test "$DCC_HOMEDIR" != @prefix@; then | |
67 DCCIFD_ARGS="-h$DCC_HOMEDIR $DCCIFD_ARGS" | |
68 fi | |
69 | |
70 if test -n "$GREY_CLIENT_ARGS"; then | |
71 if test X`expr "X$GREY_CLIENT_ARGS" : '.*\(-G\)'` = X; then | |
72 GREY_CLIENT_ARGS="-G$GREY_CLIENT_ARGS" | |
73 fi | |
74 DCCIFD_ARGS="$GREY_CLIENT_ARGS $DCCIFD_ARGS" | |
75 fi | |
76 | |
77 if test -n "$DCCIFD_USERDIRS"; then | |
78 DCCIFD_ARGS="-U$DCCIFD_USERDIRS $DCCIFD_ARGS" | |
79 fi | |
80 if test -n "$DCCIFD_WHITECLNT"; then | |
81 DCCIFD_ARGS="-w$DCCIFD_WHITECLNT $DCCIFD_ARGS" | |
82 fi | |
83 if test -n "$DCCIFD_LOGDIR"; then | |
84 # add extra quotes for '?' not present in dcc_conf | |
85 if expr "$DCCIFD_LOGDIR" : '[DHM]?' >/dev/null; then | |
86 DCCIFD_ARGS="'-l$DCCIFD_LOGDIR' $DCCIFD_ARGS" | |
87 else | |
88 DCCIFD_ARGS="-l$DCCIFD_LOGDIR $DCCIFD_ARGS" | |
89 fi | |
90 fi | |
91 | |
92 CKS="$REP_ARGS" | |
93 if test -n "$DCCIFD_LOG_AT$DCCIFD_REJECT_AT"; then | |
94 for CK in ${DCCIFD_CKSUMS:=CMN} $DCCIFD_XTRA_CKSUMS; do | |
95 CKS="$CKS -t$CK,$DCCIFD_LOG_AT,$DCCIFD_REJECT_AT" | |
96 done | |
97 fi | |
98 | |
99 DCCIFD_ARGS="$CKS $DNSBL_ARGS $DCC_LOG_ARGS $DCCIFD_ARGS" | |
100 | |
101 | |
102 | |
103 USAGE="`basename $0`: [-xv] [-h homedir] [-r rundir] [-a args]" | |
104 OPTIND=1 | |
105 while getopts "xvAh:r:a:" c; do | |
106 case $c in | |
107 x) ;; | |
108 v) ;; | |
109 A) ;; | |
110 h) ;; | |
111 r) DCC_RUNDIR="$OPTARG";; | |
112 a) DCCIFD_ARGS="$DCCIFD_ARGS $OPTARG";; | |
113 *) eval $DCC_LOGGER "$USAGE"; exit 1;; | |
114 esac | |
115 done | |
116 shift `expr $OPTIND - 1 || true` | |
117 if test "$#" -ne 0; then | |
118 eval $DCC_LOGGER "$USAGE" | |
119 exit 1 | |
120 fi | |
121 | |
122 if test -n "$DCC_RUNDIR" -a "$DCC_RUNDIR" != @dcc_rundir@; then | |
123 DCCIFD_ARGS="-R$DCC_RUNDIR $DCCIFD_ARGS" | |
124 fi | |
125 | |
126 | |
127 # stop an existing dccifd | |
128 # signal the process group because on Linux systems signaling the main | |
129 # process does not work. See `man sigwait` on a Linux system. | |
130 PID=`cat $DCC_RUNDIR/dccifd.pid 2>/dev/null` | |
131 if test -n "$PID"; then | |
132 if test -n "$AUTOSTART"; then | |
133 if kill -0 "$PID" 2>/dev/null; then | |
134 eval $DCC_LOGGER "dccifd already running" | |
135 exit 0 | |
136 fi | |
137 else | |
138 if `kill -15 $PID 2>/dev/null`; then | |
139 CNT=0 | |
140 # try for 20 seconds to let Solaris finish waiting for DNSBL answers | |
141 while test $CNT -lt 20; do | |
142 if `/bin/kill -15 $PID 2>/dev/null`; then | |
143 if test -z "$QUIET"; then | |
144 if test $CNT -eq 0; then | |
145 echo " stopping dccifd PID $PID " | tr -d '\012' | |
146 else | |
147 echo "." | tr -d '\012' | |
148 fi | |
149 fi | |
150 sleep 1 | |
151 CNT=`expr $CNT + 1` | |
152 else | |
153 break | |
154 fi | |
155 done | |
156 /bin/kill -9 $PID 2>/dev/null | |
157 if test $CNT -ne 0 -a -z "$QUIET"; then | |
158 echo | |
159 fi | |
160 fi | |
161 fi | |
162 fi | |
163 | |
164 | |
165 if test -z "$AUTOSTART"; then | |
166 case "$DCCIFD_ENABLE" in | |
167 [oO][nN]);; | |
168 *) exit 0 ;; | |
169 esac | |
170 fi | |
171 | |
172 if test ! -x $DCC_LIBEXEC/dccifd; then | |
173 if test -z "$AUTOSTART"; then | |
174 eval $DCC_LOGGER "cannot start dccifd because it has not been installed" | |
175 fi | |
176 exit 0 | |
177 fi | |
178 | |
179 if test ! -d $DCC_RUNDIR; then | |
180 mkdir $DCC_RUNDIR | |
181 fi | |
182 | |
183 # first try to use `su -` to set limits | |
184 # fall back to -I for systems where su requires a valid shell in | |
185 # /etc/passwd but where the dcc user does not have one | |
186 if test -n "$DCCUID" -a X"$DCCUID" != X"$USER"; then | |
187 if test -d "$DCC_HOMEDIR"; then | |
188 chown $DCCUID "$DCC_HOMEDIR" | |
189 fi | |
190 if test -d "$DCC_RUNDIR"; then | |
191 chown $DCCUID "$DCC_RUNDIR" | |
192 fi | |
193 if @DCC_SU@ $DCCUID -c date >/dev/null 2>&1; then | |
194 @DCC_SU@ $DCCUID -c "$DCC_LIBEXEC/dccifd $DCCIFD_ARGS" | |
195 exit | |
196 fi | |
197 DCCIFD_ARGS="-I$DCCUID $DCCIFD_ARGS" | |
198 fi | |
199 eval $DCC_LIBEXEC/dccifd $DCCIFD_ARGS |