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