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