1#! /bin/sh 2# chkconfig: - 91 35 3# description: This package is an implementation of "AFP over TCP" 4# and provides printer, file sharing, and routing 5# services via legacy AppleTalk networking protocol. 6# 7# Netatalk daemons. 8# If you use AppleTalk, 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 12ATALK_BIN=:BINDIR: 13ATALK_CONF_DIR=:ETCDIR: 14ATALK_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# default 23ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1` 24ATALK_UNIX_CHARSET='LOCALE' 25ATALK_MAC_CHARSET='MAC_ROMAN' 26 27CNID_METAD_RUN=yes 28AFPD_RUN=yes 29AFPD_MAX_CLIENTS=20 30AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so" 31AFPD_GUEST=nobody 32CNID_CONFIG="-l log_note" 33 34ATALKD_RUN=no 35PAPD_RUN=no 36TIMELORD_RUN=no 37A2BOOT_RUN=no 38ATALK_ZONE= 39ATALK_BGROUND=no 40 41# read in netatalk configuration 42if [ -f ${ATALK_CONF_DIR}/netatalk.conf ]; then 43 . ${ATALK_CONF_DIR}/netatalk.conf 44fi 45 46# initialize return values 47RETVAL=1 48RETVAL_ATALKD=0 49RETVAL_PAPD=0 50RETVAL_CNID_METAD=0 51RETVAL_AFPD=0 52 53# startup code for everything 54atalk_startup() { 55 # Check that networking is up. 56 if [ ${NETWORKING} = "no" ]; then 57 echo "[Network isn't started]"; 58 exit 1; 59 fi 60 61 if [ ! -f ${ATALK_CONF_DIR}/netatalk.conf ]; then 62 echo "[${ATALK_CONF_DIR}/netatalk.conf not found]"; 63 exit 6; 64 fi 65 66 if [ x"${ATALKD_RUN}" != x"no" -a -x ${ATALK_SBIN}/atalkd ]; then 67 # Quickly probe for appletalk and warn if we can't find it 68 #/sbin/modprobe appletalk || echo "[could not load appletalk module]" 69 # Check for IP Encapsulation support 70 #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]" 71 echo -n " Starting atalkd:" 72 daemon ${ATALK_SBIN}/atalkd 73 RETVAL_ATALKD=$? 74 echo 75 76 if [ -x ${ATALK_BIN}/nbprgstr ]; then 77 action " Registering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\" 78 action " Registering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\" 79 fi 80 81 if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then 82 echo -n " Starting papd:" 83 daemon ${ATALK_SBIN}/papd 84 RETVAL_PAPD=$? 85 echo 86 fi 87 88 # check for timelord in bin directory 89 if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then 90 echo -n " Starting timelord" 91 daemon ${ATALK_BIN}/timelord 92 echo 93 fi 94 95 # check for timelord in sbin directory 96 if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then 97 echo -n " Starting timelord" 98 daemon ${ATALK_SBIN}/timelord 99 echo 100 fi 101 102 # check for a2boot in bin directory 103 if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then 104 echo -n " Starting a2boot" 105 daemon ${ATALK_BIN}/a2boot 106 echo 107 fi 108 109 # check for a2boot in sbin directory 110 if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then 111 echo -n " Starting a2boot" 112 daemon ${ATALK_SBIN}/a2boot 113 echo 114 fi 115 116 fi 117 118 if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ] ; then 119 echo -n " Starting cnid_metad:" 120 daemon ${ATALK_SBIN}/cnid_metad $CNID_CONFIG 121 RETVAL_CNID_METAD=$? 122 echo 123 fi 124 125 if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then 126 echo -n " Starting afpd:" 127 daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \ 128 -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\" 129 RETVAL_AFPD=$? 130 echo 131 fi 132 133 if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then 134 RETVAL=0 135 touch /var/lock/subsys/atalk || RETVAL=1 136 fi 137} 138 139case "$1" in 140'start') 141 echo -n 'Starting Netatalk services: ' 142 if [ x"${ATALK_BGROUND}" = x"yes" -a x"${ATALKD_RUN}" != x"no" ]; then 143 echo -n "(backgrounded)" 144 atalk_startup >& /dev/null & 145 else 146 echo 147 atalk_startup 148 fi 149 echo 150 ;; 151'stop') 152 echo 'Shutting down Netatalk services: ' 153 if [ x"${ATALKD_RUN}" != x"no" ]; then 154 if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then 155 echo -n " Stopping papd:" 156 killproc papd 157 RETVAL_PAPD=$? 158 echo 159 fi 160 161 # checking for timelord in bin directory 162 if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then 163 echo -n " Stopping timelord:" 164 killproc timelord 165 echo 166 fi 167 168 # checking for timelord in sbin directory 169 if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then 170 echo -n " Stopping timelord:" 171 killproc timelord 172 echo 173 fi 174 175 # checking for a2boot in bin directory 176 if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then 177 echo -n " Stopping a2boot:" 178 killproc a2boot 179 echo 180 fi 181 182 # checking for a2boot in sbin directory 183 if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then 184 echo -n " Stopping a2boot:" 185 killproc a2boot 186 echo 187 fi 188 189 action " Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\" 190 action " Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\" 191 192 # kill atalkd last, since without it the plumbing goes away. 193 if [ -x ${ATALK_SBIN}/atalkd ]; then 194 echo -n " Stopping atalk:" 195 killproc atalkd 196 RETVAL_ATALKD=$? 197 echo 198 fi 199 fi 200 201 # kill this separately as we also do AFP/tcp 202 if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then 203 echo -n " Stopping afpd:" 204 killproc afpd 205 RETVAL_AFPD=$? 206 echo 207 fi 208 209 if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then 210 echo -n " Stopping cnid_metad:" 211 killproc cnid_metad 212 RETVAL_CNID_METAD=$? 213 echo 214 fi 215 216 if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then 217 RETVAL=0 218 rm -f /var/lock/subsys/atalk || RETVAL=1 219 fi 220 echo "" 221 ;; 222 'restart'|'reload') 223 $0 stop 224 $0 start 225 RETVAL=$? 226 ;; 227 'status') 228 status atalkd 229 status papd 230 status timelord 231 status a2boot 232 status cnid_metad 233 status afpd 234 RETVAL=$? 235 ;; 236 *) 237 echo "Usage: $0 {start|stop|restart|reload|status}" 238 exit 2 239esac 240 241exit $RETVAL 242