]> git.pld-linux.org Git - packages/netatalk.git/blob - netatalk.init
- fix format string warnings
[packages/netatalk.git] / netatalk.init
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 # Quickly probe for appletalk and warn if we can't find it
19 /sbin/modprobe appletalk || echo "[could not load appletalk module]"
20
21 # Check for IP Encapsulation support
22 #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]"
23
24 # read in netatalk configuration
25 . /etc/sysconfig/netatalk
26
27 # Check that networking is up.
28 if is_yes "${NETWORKING}"; then
29         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
30                 # nls "ERROR: Networking is down. %s can't be run." <service>
31                 msg_network_down "AppleTalk"
32                 exit 1
33         fi
34 else
35         exit 0
36 fi
37
38 # initialize return values
39 RETVAL=1
40 RETVAL_ATALKD=0
41 RETVAL_PAPD=0
42 RETVAL_AFPD=0
43
44 start() {
45         if [ -f /var/lock/subsys/atalk ]; then
46                 msg_already_running "AppleTalk"
47                 exit 0
48         fi
49
50         if is_yes "${ATALKD_RUN}"; then 
51                 msg_starting "atalkd"
52                 daemon atalkd
53                 RETVAL_ATALKD=$?
54                 run_cmd -a "$(nls "Registering %s" "${ATALK_NAME}:Workstation${ATALK_ZONE}:")" "nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\""
55                 run_cmd -a "$(nls "Registering %s" "${ATALK_NAME}:netatalk${ATALK_ZONE}:")" "nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\""
56                 if is_yes "${PAPD_RUN}"; then
57                         msg_starting "papd"
58                         daemon papd
59                         RETVAL_PAPD=$?
60                 fi
61         fi
62
63         if is_yes "${TIMELORD_RUN}"; then
64                 msg_starting "timelord"
65                 daemon timelord
66         fi
67
68         if is_yes "${AFPD_RUN}"; then
69                 msg_starting "afpd"
70                 daemon afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
71                 RETVAL_AFPD=$?
72         fi
73
74         if [ "$RETVAL_ATALKD" -eq 0 -a "$RETVAL_PAPD" -eq 0 -a "$RETVAL_AFPD" -eq 0 ]; then
75                 RETVAL=0
76                 touch /var/lock/subsys/atalk || RETVAL=1
77         fi
78 }
79
80 stop() {
81         if [ ! -f /var/lock/subsys/atalk ]; then
82                 msg_not_running "AppleTalk"
83                 exit 0
84         fi
85
86         if is_yes "${ATALKD_RUN}"; then
87                 if is_yes "${PAPD_RUN}"; then
88                         msg_stopping "papd"
89                         killproc papd
90                 fi
91
92                 if is_yes "${TIMELORD_RUN}"; then
93                         msg_stopping "timelord"
94                         killproc timelord
95                 fi
96
97                 run_cmd "$(nls "Unregistering %s" "${ATALK_NAME}:Workstation${ATALK_ZONE}:")" "nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\""
98                 run_cmd "$(nls "Unregistering %s" "${ATALK_NAME}:netatalk${ATALK_ZONE}:")" "nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\""
99
100                 msg_stopping "atalk"
101                 killproc atalkd
102         fi
103
104         if  is_yes "${AFPD_RUN}"; then
105                 msg_stopping "afpd"
106                 killproc afpd
107         fi
108         rm -f /var/lock/subsys/atalk >/dev/null 2>&1
109 }
110
111 RETVAL=0
112 # startup code for everything
113 case "$1" in
114   start)
115         start
116         ;;
117
118   stop)
119         stop
120         ;;
121   restart|force-reload)
122         stop
123         start
124         ;;
125   status)
126         if is_yes "${ATALKD_RUN}"; then 
127             if is_yes "${PAPD_RUN}"; then
128                 status papd
129             fi
130             
131             if is_yes "${TIMELORD_RUN}"; then
132                 status timelord
133             fi
134             
135             if  is_yes "${AFPD_RUN}"; then
136                 status afpd
137             fi
138             status atalkd
139             nbplkup ${ATALK_NAME}
140         fi
141         exit $?
142         ;;
143   *)
144         msg_usage "$0 {start|stop|restart|force-reload|status}"
145         exit 3
146 esac
147
148 exit $RETVAL
This page took 0.032668 seconds and 3 git commands to generate.