]> arthur.barton.de Git - netatalk.git/blob - distrib/initscripts/rc.atalk.redhat.tmpl
Fix cnid_metad -l option
[netatalk.git] / distrib / initscripts / rc.atalk.redhat.tmpl
1 #! /bin/sh
2 # chkconfig: 345 91 35
3 # description: This package enables Linux to talk to Macintosh
4 #              computers via the AppleTalk networking protocol and 
5 #              provides printer, file sharing, and AppleTalk routing 
6 #              services.   
7 #
8 # AppleTalk daemons. Make sure not to start atalkd in the background:
9 # its data structures must have time to stablize before running the
10 # other processes.
11
12 ATALK_BIN=:BINDIR:
13 ATALK_CONF_DIR=:ETCDIR:
14 ATALK_SBIN=:SBINDIR:
15
16 # Source function library.
17 . /etc/rc.d/init.d/functions
18
19 # Source networking configuration.
20 . /etc/sysconfig/network
21
22 if [ ! -x ${ATALK_SBIN}/atalkd ]; then
23      # Quickly probe for appletalk and warn if we can't find it
24      #/sbin/modprobe appletalk || echo "[could not load appletalk module]"
25      # Check for IP Encapsulation support
26      #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]"
27      echo "[${ATALK_SBIN}/atalkd not found.  Did it compile?]";
28      exit 0;
29 fi
30
31 if [ ! -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
32      echo "[${ATALK_CONF_DIR}/netatalk.conf not found]";
33      exit 0;
34 fi
35
36 # read in netatalk configuration
37 . ${ATALK_CONF_DIR}/netatalk.conf
38
39 # Check that networking is up.
40 if [ ${NETWORKING} = "no" ]; then
41      echo "[Network isn't started]"; 
42      exit 0;
43 fi
44
45 # initialize return values
46 RETVAL=1
47 RETVAL_ATALKD=0
48 RETVAL_PAPD=0
49 RETVAL_CNID_METAD=0
50 RETVAL_AFPD=0
51
52 # startup code for everything
53 atalk_startup() {
54     if [ x"${ATALKD_RUN}" != x"no" ]; then 
55         echo -n "  Starting atalkd:"
56         daemon ${ATALK_SBIN}/atalkd
57         RETVAL_ATALKD=$?
58         echo
59
60         if [ -x ${ATALK_BIN}/nbprgstr ]; then   
61             action "  Registering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
62             action "  Registering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
63         fi      
64
65         if [ x"${PAPD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/papd ]; then
66             echo -n "  Starting papd:"
67             daemon ${ATALK_SBIN}/papd
68             RETVAL_PAPD=$?
69             echo
70         fi
71
72         # check for timelord in bin directory
73         if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_BIN}/timelord ]; then
74             echo -n "  Starting timelord"
75             daemon ${ATALK_BIN}/timelord
76             echo
77         fi
78
79         # check for timelord in sbin directory
80         if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/timelord ]; then
81             echo -n "  Starting timelord"
82             daemon ${ATALK_SBIN}/timelord
83             echo
84         fi
85
86         # check for a2boot in bin directory
87         if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_BIN}/a2boot ]; then
88             echo -n "  Starting a2boot"
89             daemon ${ATALK_BIN}/a2boot
90             echo
91         fi
92
93         # check for a2boot in sbin directory
94         if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/a2boot ]; then
95             echo -n "  Starting a2boot"
96             daemon ${ATALK_SBIN}/a2boot
97             echo
98         fi
99
100     fi
101
102     if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ] ; then
103             echo -n "  Starting cnid_metad:"
104         if [ "x$CNID_DBD_LOGCONFIG" = "x" ]; then
105             daemon ${ATALK_SBIN}/cnid_metad
106         else
107             daemon ${ATALK_SBIN}/cnid_metad -l "$CNID_DBD_LOGCONFIG"
108         fi
109             RETVAL_CNID_METAD=$?
110             echo
111     fi
112
113     if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
114             echo -n "  Starting afpd:"
115             daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
116                -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
117             RETVAL_AFPD=$?
118             echo
119     fi
120
121     if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
122         RETVAL=0
123         touch /var/lock/subsys/atalk || RETVAL=1
124     fi
125 }
126
127 case "$1" in
128 'start')
129         echo -n 'Starting AppleTalk services: '
130         if [ x"${ATALK_BGROUND}" = x"yes" ]; then 
131             echo -n "(backgrounded)"
132             atalk_startup >& /dev/null &
133         else
134             echo
135             atalk_startup
136         fi
137         echo 
138         ;;
139 'stop')
140         echo 'Shutting down AppleTalk services: '
141         if [ x"${ATALKD_RUN}" != x"no" ]; then
142             if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
143                 echo -n "  Stopping papd:"
144                 killproc papd
145                 RETVAL_PAPD=$?
146                 echo
147             fi
148
149             # checking for timelord in bin directory
150             if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
151                 echo -n "  Stopping timelord:"
152                 killproc timelord
153                 echo
154             fi
155
156             # checking for timelord in sbin directory
157             if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
158                 echo -n "  Stopping timelord:"
159                 killproc timelord
160                 echo
161             fi
162
163             # checking for a2boot in bin directory
164             if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
165                 echo -n "  Stopping a2boot:"
166                 killproc a2boot
167                 echo
168             fi
169
170             # checking for a2boot in sbin directory
171             if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
172                 echo -n "  Stopping a2boot:"
173                 killproc a2boot
174                 echo
175             fi
176
177             action "  Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
178             action "  Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
179
180             # kill atalkd last, since without it the plumbing goes away.
181             if [ -x ${ATALK_SBIN}/atalkd ]; then
182                 echo -n "  Stopping atalk:"
183                 killproc atalkd
184                 RETVAL_ATALKD=$?
185                 echo
186             fi
187         fi
188
189         # kill this separately as we also do AFP/tcp
190         if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
191             echo -n "  Stopping afpd:"
192             killproc afpd
193             RETVAL_AFPD=$?
194             echo
195         fi
196
197         if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
198             echo -n "  Stopping cnid_metad:"
199             killproc cnid_metad
200             RETVAL_CNID_METAD=$?
201             echo
202         fi
203
204         if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
205             RETVAL=0
206             rm -f /var/lock/subsys/atalk || RETVAL=1
207         fi
208         echo ""
209         ;;
210   'restart'|'reload')
211         $0 stop
212         $0 start
213         RETVAL=$?
214         ;;
215   'status')
216         status atalkd
217         RETVAL=$?
218         ;;
219   *)
220         echo "Usage: atalk {start|stop|restart|status}"
221         exit 1
222 esac
223
224 exit $RETVAL