]> arthur.barton.de Git - netatalk.git/blob - distrib/initscripts/rc.atalk.redhat.tmpl
Naming issues. From HAT.
[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 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         daemon ${ATALK_SBIN}/cnid_metad $CNID_CONFIG
105             RETVAL_CNID_METAD=$?
106             echo
107     fi
108
109     if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
110             echo -n "  Starting afpd:"
111             daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
112                -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
113             RETVAL_AFPD=$?
114             echo
115     fi
116
117     if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
118         RETVAL=0
119         touch /var/lock/subsys/atalk || RETVAL=1
120     fi
121 }
122
123 case "$1" in
124 'start')
125         echo -n 'Starting Netatalk services: '
126         if [ x"${ATALK_BGROUND}" = x"yes" ]; then 
127             echo -n "(backgrounded)"
128             atalk_startup >& /dev/null &
129         else
130             echo
131             atalk_startup
132         fi
133         echo 
134         ;;
135 'stop')
136         echo 'Shutting down Netatalk services: '
137         if [ x"${ATALKD_RUN}" != x"no" ]; then
138             if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
139                 echo -n "  Stopping papd:"
140                 killproc papd
141                 RETVAL_PAPD=$?
142                 echo
143             fi
144
145             # checking for timelord in bin directory
146             if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
147                 echo -n "  Stopping timelord:"
148                 killproc timelord
149                 echo
150             fi
151
152             # checking for timelord in sbin directory
153             if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
154                 echo -n "  Stopping timelord:"
155                 killproc timelord
156                 echo
157             fi
158
159             # checking for a2boot in bin directory
160             if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
161                 echo -n "  Stopping a2boot:"
162                 killproc a2boot
163                 echo
164             fi
165
166             # checking for a2boot in sbin directory
167             if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
168                 echo -n "  Stopping a2boot:"
169                 killproc a2boot
170                 echo
171             fi
172
173             action "  Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
174             action "  Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
175
176             # kill atalkd last, since without it the plumbing goes away.
177             if [ -x ${ATALK_SBIN}/atalkd ]; then
178                 echo -n "  Stopping atalk:"
179                 killproc atalkd
180                 RETVAL_ATALKD=$?
181                 echo
182             fi
183         fi
184
185         # kill this separately as we also do AFP/tcp
186         if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
187             echo -n "  Stopping afpd:"
188             killproc afpd
189             RETVAL_AFPD=$?
190             echo
191         fi
192
193         if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
194             echo -n "  Stopping cnid_metad:"
195             killproc cnid_metad
196             RETVAL_CNID_METAD=$?
197             echo
198         fi
199
200         if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
201             RETVAL=0
202             rm -f /var/lock/subsys/atalk || RETVAL=1
203         fi
204         echo ""
205         ;;
206   'restart'|'reload')
207         $0 stop
208         $0 start
209         RETVAL=$?
210         ;;
211   'status')
212         status atalkd
213         RETVAL=$?
214         ;;
215   *)
216         echo "Usage: atalk {start|stop|restart|status}"
217         exit 1
218 esac
219
220 exit $RETVAL