]> arthur.barton.de Git - netatalk.git/blob - distrib/initscripts/rc.atalk.redhat.tmpl
Changes made by Michel Jouvin - jouvin@lal.in2p3.fr - 23/11/2000
[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 test -x ${ATALK_SBIN}/atalkd || exit 0
23
24 test -f ${ATALK_CONF_DIR}/netatalk.conf || exit 0
25
26 # read in netatalk configuration
27 . ${ATALK_CONF_DIR}/netatalk.conf
28
29 # Check that networking is up.
30 [ ${NETWORKING} = "no" ] && exit 0
31
32 # initialize return values
33 RETVAL=1
34 RETVAL_ATALKD=0
35 RETVAL_PAPD=0
36 RETVAL_AFPD=0
37
38 # startup code for everything
39 atalk_startup() {
40     if [ x"${ATALKD_RUN}" != x"no" ]; then 
41         daemon ${ATALK_SBIN}/atalkd
42         RETVAL_ATALKD=$?
43
44         if [ -x ${ATALK_BIN}/nbprgstr ]; then   
45             ${ATALK_BIN}/nbprgstr -p 4 "${ATALK_NAME}:Workstation${ATALK_ZONE}"
46             ${ATALK_BIN}/nbprgstr -p 4 "${ATALK_NAME}:netatalk${ATALK_ZONE}"
47         fi      
48
49         if [ x"${PAPD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/papd ]; then
50             daemon ${ATALK_SBIN}/papd
51             RETVAL_PAPD=$?
52         fi
53
54         # check for timelord in bin directory
55         if [ -x ${ATALK_BIN}/timelord ]; then
56             daemon ${ATALK_BIN}/timelord
57         fi
58
59         # check for timelord in sbin directory
60         if [ -x ${ATALK_SBIN}/timelord ]; then
61             daemon ${ATALK_SBIN}/timelord
62         fi
63
64     fi
65
66     if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
67             daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
68                 -c ${AFPD_MAX_CLIENTS} -n "${ATALK_NAME}${ATALK_ZONE}"
69             RETVAL_AFPD=$?
70     fi
71
72     if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
73         RETVAL=0
74         touch /var/lock/subsys/atalk || RETVAL=1
75     fi
76 }
77
78 case "$1" in
79 'start')
80         echo -n 'Starting AppleTalk services: '
81         if [ x"${ATALK_BGROUND}" = x"yes" ]; then 
82             echo -n "(backgrounded)"
83             atalk_startup >& /dev/null &
84         else
85             atalk_startup
86         fi
87         echo 
88         ;;
89 'stop')
90         echo -n 'Shutting down AppleTalk services: '
91         if [ x"${ATALKD_RUN}" != x"no" ]; then
92             if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
93                 killproc papd
94                 RETVAL_PAPD=$?
95             fi
96
97             # checking for timelord in bin directory
98             if [ -x ${ATALK_BIN}/timelord ]; then
99                 killproc timelord
100             fi
101
102             # checking for timelord in sbin directory
103             if [ -x ${ATALK_SBIN}/timelord ]; then
104                 killproc timelord
105             fi
106
107             ${ATALK_BIN}/nbpunrgstr "${ATALK_NAME}:Workstation${ATALK_ZONE}"
108             ${ATALK_BIN}/nbpunrgstr "${ATALK_NAME}:netatalk${ATALK_ZONE}"
109
110             # kill atalkd last, since without it the plumbing goes away.
111             if [ -x ${ATALK_SBIN}/atalkd ]; then
112                 killproc atalkd
113                 RETVAL_ATALKD=$?
114             fi
115         fi
116
117         # kill this separately as we also do AFP/tcp
118         if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
119             killproc afpd
120             RETVAL_AFPD=$?
121         fi
122
123         if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
124             RETVAL=0
125             rm -f /var/lock/subsys/atalk || RETVAL=1
126         fi
127         echo ""
128         ;;
129   'restart'|'reload')
130         $0 stop
131         $0 start
132         RETVAL=$?
133         ;;
134   'status')
135         status atalkd
136         RETVAL=$?
137         ;;
138   *)
139         echo "Usage: atalk {start|stop|restart|status}"
140         exit 1
141 esac
142
143 exit $RETVAL