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