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