comparison misc/start-dccd.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
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.55 $Revision$
43 # @configure_input@
44
45 exec 1>&2 </dev/null
46
47 LOGGER_TAG=start-dccd
48 DCC_LOGGER="@DCC_LOGGER@"
49 DCC_HOMEDIR=@prefix@
50 VERBOSE=
51 DEBUG=
52 STOP_ARGS=
53 # check the args once to get the home directory
54 while getopts ":xvh:u:a:i:n:" c; do
55 case $c in
56 x) set -x; DEBUG=-x; VERBOSE=-v;;
57 v) VERBOSE=-v;;
58 h) CWD=`pwd`
59 DCC_HOMEDIR=`echo "$OPTARG" | sed -e "s@^[^/]@$CWD/&@"`;;
60 *) ;;
61 esac
62 done
63 if test ! -s $DCC_HOMEDIR/dcc_conf; then
64 eval $DCC_LOGGER "cannot find $DCC_HOMEDIR/dcc_conf"
65 fi
66 . $DCC_HOMEDIR/dcc_conf
67 # deal with bash reserved $UID and old versions of dcc_conf
68 if test 0"$DCC_CONF_VERSION" -lt 2 -a -z "$DCCUID" -a -n "$UID"; then
69 DCCUID="$UID"
70 fi
71 DCCD_ARGS="$DCC_LOG_ARGS $DCCD_ARGS"
72
73 USAGE="`basename $0`: [-xv] [-h homedir] [-u UID] [-a args] [-i id] [-n brand]"
74 OPTIND=1
75 while getopts "xvh:u:a:i:n:" c; do
76 case $c in
77 x) ;;
78 v) ;;
79 h) ;;
80 u) DCCUID="$OPTARG";;
81 a) DCCD_ARGS="$DCCD_ARGS $OPTARG";;
82 i) SRVR_ID="$OPTARG"; STOP_ARGS="$STOP_ARGS -i $SRVR_ID";;
83 n) BRAND="$OPTARG";;
84 *) eval $DCC_LOGGER "$USAGE"; exit 1;;
85 esac
86 done
87 shift `expr $OPTIND - 1 || true`
88 if test "$#" -ne 0; then
89 eval $DCC_LOGGER "$USAGE"
90 exit 1
91 fi
92
93 if test "$DCC_HOMEDIR" != @prefix@; then
94 DCCD_ARGS="-h$DCC_HOMEDIR $DCCD_ARGS"
95 STOP_ARGS="-h$DCC_HOMEDIR $STOP_ARGS"
96 fi
97 if test "$BRAND" != ""; then
98 BRAND="-n $BRAND"
99 fi
100 DCCD_ARGS="-i$SRVR_ID $BRAND $DCCD_ARGS"
101
102 # stop the current daemon, including giving it time to shut down gracefully
103 $DCC_LIBEXEC/stop-dccd $DEBUG $VERBOSE $STOP_ARGS
104
105 # tell dccd where to find dbclean if it is not where dccd was built to look.
106 if test "$DCC_LIBEXEC" != @libexecdir@; then
107 DCCD_ARGS="-C $DCC_LIBEXEC/dbclean $DCCD_ARGS"
108 fi
109
110 # assume unset DCCD_ENABLE is "on" for upward compatibility
111 case "$DCCD_ENABLE" in
112 [oO][fF][fF]) exit 0;;
113 esac
114 if test ! -x $DCC_LIBEXEC/dccd; then
115 eval $DCC_LOGGER "cannot start dcccd because dccd has not been installed"
116 exit 1
117 fi
118 if test -z "$SRVR_ID"; then
119 eval $DCC_LOGGER "'cannot start dccd; SRVR_ID not set in $DCC_HOMEDIR/dcc_conf'"
120 exit 1
121 fi
122
123 # first try to use `su -` to set limits
124 # fall back to -I for systems where su requires a valid shell in
125 # /etc/passwd but where the dcc user does not have one
126 if test -n "$DCCUID" -a X"$DCCUID" != X"$USER"; then
127 if @DCC_SU@ $DCCUID -c date >/dev/null 2>&1; then
128 @DCC_SU@ $DCCUID -c "$DCC_LIBEXEC/dccd $DCCD_ARGS"
129 exit
130 fi
131 DCCD_ARGS="-I,$DCCUID $DCCD_ARGS"
132 fi
133 eval $DCC_LIBEXEC/dccd $DCCD_ARGS