]> arthur.barton.de Git - netatalk.git/blob - distrib/initscripts/rc.atalk.redhat
moved "bindir" to prefix/bin/ to solve passing as variables problem from autoconf
[netatalk.git] / distrib / initscripts / rc.atalk.redhat
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 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # Source networking configuration.
16 . /etc/sysconfig/network
17
18 test -x :SBINDIR:/atalkd || exit 0
19
20 test -f :ETCDIR:/netatalk.conf || exit 0
21
22 # read in netatalk configuration
23 . :ETCDIR:/netatalk.conf
24
25 # Check that networking is up.
26 [ ${NETWORKING} = "no" ] && exit 0
27
28 # initialize return values
29 RETVAL=1
30 RETVAL_ATALKD=0
31 RETVAL_PAPD=0
32 RETVAL_AFPD=0
33
34 # startup code for everything
35 atalk_startup() {
36     if [ x"${ATALKD_RUN}" != x"no" ]; then 
37         daemon :SBINDIR:/atalkd
38         RETVAL_ATALKD=$?
39
40         if [ -x :BINDIR:/nbprgstr ]; then       
41             :BINDIR:/nbprgstr -p 4 "${ATALK_NAME}:Workstation${ATALK_ZONE}"
42             :BINDIR:/nbprgstr -p 4 "${ATALK_NAME}:netatalk${ATALK_ZONE}"
43         fi      
44
45         if [ x"${PAPD_RUN}" = x"yes"  -a -x :SBINDIR:/papd ]; then
46             daemon :SBINDIR:/papd
47             RETVAL_PAPD=$?
48         fi
49
50         if [ -x :SBINDIR:/timelord ]; then
51             daemon :SBINDIR:/timelord
52         fi
53
54     fi
55
56     if [ x"${AFPD_RUN}" = x"yes" -a -x :SBINDIR:/afpd ] ; then
57             daemon :SBINDIR:/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
58                 -c ${AFPD_MAX_CLIENTS} -n "${ATALK_NAME}${ATALK_ZONE}"
59             RETVAL_AFPD=$?
60     fi
61
62     if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
63         RETVAL=0
64         touch /var/lock/subsys/atalk || RETVAL=1
65     fi
66 }
67
68 case "$1" in
69 'start')
70         echo -n 'Starting AppleTalk services: '
71         if [ x"${ATALK_BGROUND}" = x"yes" ]; then 
72             echo -n "(backgrounded)"
73             atalk_startup >& /dev/null &
74         else
75             atalk_startup
76         fi
77         echo 
78         ;;
79 'stop')
80         echo -n 'Shutting down AppleTalk services: '
81         if [ x"${ATALKD_RUN}" != x"no" ]; then
82             if [ x"${PAPD_RUN}" = x"yes" -a -x :SBINDIR:/papd ]; then
83                 killproc papd
84                 RETVAL_PAPD=$?
85             fi
86
87             if [ -x :SBINDIR:/timelord ]; then
88                 killproc timelord
89             fi
90
91             :BINDIR:/nbpunrgstr "${ATALK_NAME}:Workstation${ATALK_ZONE}"
92             :BINDIR:/nbpunrgstr "${ATALK_NAME}:netatalk${ATALK_ZONE}"
93
94             # kill atalkd last, since without it the plumbing goes away.
95             if [ -x :SBINDIR:/atalkd ]; then
96                 killproc atalkd
97                 RETVAL_ATALKD=$?
98             fi
99         fi          
100
101         # kill this separately as we also do AFP/tcp
102         if [ x"${AFPD_RUN}" = x"yes" -a -x :SBINDIR:/afpd ]; then
103             killproc afpd
104             RETVAL_AFPD=$?
105         fi
106
107         if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
108             RETVAL=0
109             rm -f /var/lock/subsys/atalk || RETVAL=1
110         fi
111         echo ""
112         ;;
113   'restart'|'reload')
114         $0 stop
115         $0 start
116         RETVAL=$?
117         ;;
118   'status')
119         status atalkd
120         RETVAL=$?
121         ;;
122   *)
123         echo "Usage: atalk {start|stop|restart|status}"
124         exit 1
125 esac
126
127 exit $RETVAL