]> arthur.barton.de Git - netatalk.git/blob - distrib/initscripts/rc.atalk.cobalt
Merge 2-1
[netatalk.git] / distrib / initscripts / rc.atalk.cobalt
1 #!/bin/sh
2 #
3 # chkconfig: 345 91 35
4 # description: Starts and stops the atalk, afpd & papd daemons for
5 #              providing AppleTalk networking services.
6 #
7
8 # Source function library.
9 . /etc/rc.d/init.d/functions
10
11 # set lcd stuff up if necessary
12 if [ x"$LCD_STOP" = x"" ]; then
13         LCD_STOP="/sbin/stoplcd"
14 fi
15 if [ x"$LCD_SWRITE" = x"" ]; then
16         LCD_SWRITE="/sbin/swritelcd"
17 fi
18
19 # set up i18n stuff if necessary
20 if [ -x /usr/local/sbin/getmsg ]; then
21         GETMSG=/usr/local/sbin/getmsg
22         START_MSG1=atalkStart1
23         START_MSG2=atalkStart2
24         STOP_MSG1=atalkStop1
25         STOP_MSG2=atalkStop2
26 else
27         GETMSG=getmsg
28         START_MSG1=atalk_start_1
29         START_MSG2=atalk_start_2
30         STOP_MSG1=atalk_stop_1
31         STOP_MSG2=atalk_stop_2
32 fi
33
34 # Source networking configuration.
35 . /etc/sysconfig/network
36
37 test -x /usr/sbin/atalkd || exit 0
38
39 test -f /etc/atalk/netatalk.conf || exit 0
40
41 # read in netatalk configuration
42 . /etc/atalk/netatalk.conf
43
44 # Check that networking is up.
45 [ ${NETWORKING} = "no" ] && exit 0
46
47 # initialize return values
48 RETVAL=1
49 RETVAL_ATALKD=0
50 RETVAL_PAPD=0
51 RETVAL_CNID_METAD=0
52 RETVAL_AFPD=0
53
54 # startup code for everything
55 atalk_startup() {
56     if [ x"${ATALKD_RUN}" != x"no" ]; then 
57         daemon /usr/sbin/atalkd
58         RETVAL_ATALKD=$?
59
60         if [ -x /usr/bin/nbprgstr ]; then       
61             /usr/bin/nbprgstr -p 4 "${ATALK_NAME}:Workstation${ATALK_ZONE}"
62             /usr/bin/nbprgstr -p 4 "${ATALK_NAME}:netatalk${ATALK_ZONE}"
63         fi      
64             
65         if [ x"${PAPD_RUN}" = x"yes"  -a -x /usr/sbin/papd ]; then
66             daemon /usr/sbin/papd
67             RETVAL_PAPD=$?
68         fi
69
70         if [ -x /usr/sbin/timelord ]; then
71             daemon /usr/sbin/timelord
72         fi
73     fi
74
75     if [ x"${CNID_METAD_RUN}" = x"yes" -a -x /usr/sbin/cnid_metad ] ; then
76             daemon /usr/sbin/cnid_metad $CNID_CONFIG
77             RETVAL_CNID_METAD=$?
78     fi
79
80     if [ x"${AFPD_RUN}" = x"yes" -a -x /usr/sbin/afpd ] ; then
81             daemon /usr/sbin/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
82                 -c ${AFPD_MAX_CLIENTS} -n "${ATALK_NAME}${ATALK_ZONE}"
83             RETVAL_AFPD=$?
84     fi
85
86     if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
87         RETVAL=0
88         touch /var/lock/subsys/atalk || RETVAL=1
89     fi
90 }
91
92 case "$1" in
93 'start')
94         LINE1=`$GETMSG $START_MSG1`
95         LINE2=`$GETMSG $START_MSG2`
96         $LCD_STOP
97         $LCD_SWRITE "$LINE1" "$LINE2" &>/dev/null &
98         echo -n 'Starting AppleTalk services: '
99         if [ x"${ATALK_BGROUND}" = x"yes" ]; then 
100             echo -n "(backgrounded)"
101             atalk_startup >& /dev/null &
102         else
103             atalk_startup
104         fi
105         echo 
106         touch /var/lock/subsys/atalk
107         ;;
108 'stop')
109         LINE1=`$GETMSG $STOP_MSG1`
110         LINE2=`$GETMSG $STOP_MSG2`
111         $LCD_STOP
112         $LCD_SWRITE "$LINE1" "$LINE2" &>/dev/null &
113         echo -n 'Shutting down AppleTalk services: '
114         if [ x"${ATALKD_RUN}" != x"no" ]; then
115             if [ x"${PAPD_RUN}" = x"yes" -a -x /usr/sbin/papd ]; then
116                 killproc papd
117                 RETVAL_PAPD=$?
118             fi
119
120             /usr/bin/nbpunrgstr "${ATALK_NAME}:Workstation${ATALK_ZONE}"
121             /usr/bin/nbpunrgstr "${ATALK_NAME}:netatalk${ATALK_ZONE}"
122
123             # kill atalkd last, since without it the plumbing goes away.
124             if [ -x /usr/sbin/atalkd ]; then
125                 killproc atalkd
126                 RETVAL_ATALKD=$?
127             fi
128         fi          
129
130         # kill this separately as we also do AFP/tcp
131         if [ x"${AFPD_RUN}" = x"yes" -a -x /usr/sbin/afpd ]; then
132             killproc afpd
133             RETVAL_AFPD=$?
134         fi
135
136         if [ x"${CNID_METAD_RUN}" = x"yes" -a -x /usr/sbin/cnid_metad ]; then
137             killproc cnid_metad
138             RETVAL_CNID_METAD=$?
139         fi
140
141         if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
142             RETVAL=0
143             rm -f /var/lock/subsys/atalk || RETVAL=1
144         fi
145         echo ""
146         ;;
147   restart|reload)
148         $0 stop
149         $0 start
150         ;;
151   status)
152         status atalkd
153         ;;
154   *)
155         echo "Usage: atalk {start|stop|restart|status}"
156         exit 1
157 esac
158
159 exit $RETVAL