#! /bin/sh
# chkconfig: - 91 35
-# description: This package is an implementation of "AFP over TCP"
-# and provides printer, file sharing, and routing
-# services via legacy AppleTalk networking protocol.
+# description: Netatalk AFP fileserver for Macintosh clients
#
# Netatalk :NETATALK_VERSION: daemons.
-# If you use AppleTalk, Make sure not to start atalkd in the background:
-# its data structures must have time to stablize before running the
-# other processes.
ATALK_BIN=:BINDIR:
ATALK_CONF_DIR=:ETCDIR:
# Source networking configuration.
. /etc/sysconfig/network
-# default
-ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`
-ATALK_UNIX_CHARSET='LOCALE'
-ATALK_MAC_CHARSET='MAC_ROMAN'
-
-CNID_METAD_RUN=yes
-AFPD_RUN=yes
-AFPD_MAX_CLIENTS=20
-AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"
-AFPD_GUEST=nobody
-CNID_CONFIG="-l log_note"
-
-ATALKD_RUN=no
-PAPD_RUN=no
-TIMELORD_RUN=no
-A2BOOT_RUN=no
-ATALK_ZONE=
-ATALK_BGROUND=no
-
-# read in netatalk configuration
-if [ -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
- . ${ATALK_CONF_DIR}/netatalk.conf
-fi
-
# initialize return values
RETVAL=1
-RETVAL_ATALKD=0
-RETVAL_PAPD=0
RETVAL_CNID_METAD=0
RETVAL_AFPD=0
atalk_startup() {
# Check that networking is up.
if [ ${NETWORKING} = "no" ]; then
- echo "[Network isn't started]";
- exit 1;
- fi
-
- if [ ! -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
- echo "[${ATALK_CONF_DIR}/netatalk.conf not found]";
- exit 6;
- fi
-
- if [ x"${ATALKD_RUN}" != x"no" -a -x ${ATALK_SBIN}/atalkd ]; then
- # Quickly probe for appletalk and warn if we can't find it
- #/sbin/modprobe appletalk || echo "[could not load appletalk module]"
- # Check for IP Encapsulation support
- #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]"
- echo -n " Starting atalkd:"
- daemon ${ATALK_SBIN}/atalkd
- RETVAL_ATALKD=$?
- echo
-
- if [ -x ${ATALK_BIN}/nbprgstr ]; then
- action " Registering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
- action " Registering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
- fi
-
- if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
- echo -n " Starting papd:"
- daemon ${ATALK_SBIN}/papd
- RETVAL_PAPD=$?
- echo
- fi
-
- # check for timelord in bin directory
- if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
- echo -n " Starting timelord"
- daemon ${ATALK_BIN}/timelord
- echo
- fi
-
- # check for timelord in sbin directory
- if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
- echo -n " Starting timelord"
- daemon ${ATALK_SBIN}/timelord
- echo
- fi
-
- # check for a2boot in bin directory
- if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
- echo -n " Starting a2boot"
- daemon ${ATALK_BIN}/a2boot
- echo
- fi
-
- # check for a2boot in sbin directory
- if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
- echo -n " Starting a2boot"
- daemon ${ATALK_SBIN}/a2boot
- echo
- fi
-
+ echo "[Network isn't started]";
+ exit 1;
fi
- if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ] ; then
- echo -n " Starting cnid_metad:"
- daemon ${ATALK_SBIN}/cnid_metad $CNID_CONFIG
- RETVAL_CNID_METAD=$?
- echo
+ if [ -x ${ATALK_SBIN}/cnid_metad ] ; then
+ echo -n " Starting cnid_metad:"
+ daemon ${ATALK_SBIN}/cnid_metad
+ RETVAL_CNID_METAD=$?
+ echo
fi
- if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
- echo -n " Starting afpd:"
- daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
- -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
- RETVAL_AFPD=$?
- echo
+ if [ -x ${ATALK_SBIN}/afpd ] ; then
+ echo -n " Starting afpd:"
+ daemon ${ATALK_SBIN}/afpd
+ RETVAL_AFPD=$?
+ echo
fi
- if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
+ if [ $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
RETVAL=0
- touch /var/lock/subsys/atalk || RETVAL=1
+ touch /var/lock/subsys/atalk || RETVAL=1
fi
}
case "$1" in
-'start')
- echo -n 'Starting Netatalk services: '
- if [ x"${ATALK_BGROUND}" = x"yes" -a x"${ATALKD_RUN}" != x"no" ]; then
- echo -n "(backgrounded)"
- atalk_startup >& /dev/null &
- else
- echo
- atalk_startup
- fi
- echo
- ;;
-'stop')
- echo 'Shutting down Netatalk services: '
- if [ x"${ATALKD_RUN}" != x"no" ]; then
- if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
- echo -n " Stopping papd:"
- killproc papd
- RETVAL_PAPD=$?
- echo
- fi
-
- # checking for timelord in bin directory
- if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
- echo -n " Stopping timelord:"
- killproc timelord
- echo
- fi
-
- # checking for timelord in sbin directory
- if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
- echo -n " Stopping timelord:"
- killproc timelord
- echo
- fi
-
- # checking for a2boot in bin directory
- if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
- echo -n " Stopping a2boot:"
- killproc a2boot
- echo
- fi
-
- # checking for a2boot in sbin directory
- if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
- echo -n " Stopping a2boot:"
- killproc a2boot
- echo
- fi
-
- action " Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
- action " Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
-
- # kill atalkd last, since without it the plumbing goes away.
- if [ -x ${ATALK_SBIN}/atalkd ]; then
- echo -n " Stopping atalk:"
- killproc atalkd
- RETVAL_ATALKD=$?
- echo
- fi
- fi
-
- # kill this separately as we also do AFP/tcp
- if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
- echo -n " Stopping afpd:"
- killproc afpd
- RETVAL_AFPD=$?
- echo
- fi
-
- if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
- echo -n " Stopping cnid_metad:"
- killproc cnid_metad
- RETVAL_CNID_METAD=$?
- echo
- fi
-
- if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
- RETVAL=0
- rm -f /var/lock/subsys/atalk || RETVAL=1
- fi
- echo ""
- ;;
- 'restart'|'reload')
- $0 stop
- $0 start
- RETVAL=$?
- ;;
- 'status')
- status atalkd
- status papd
- status timelord
- status a2boot
- status cnid_metad
- status afpd
- RETVAL=$?
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|reload|status}"
- exit 2
+ 'start')
+ echo -n 'Starting Netatalk services: '
+ echo
+ atalk_startup
+ echo
+ ;;
+ 'stop')
+ echo 'Shutting down Netatalk services: '
+ if [ -x ${ATALK_SBIN}/afpd ]; then
+ echo -n " Stopping afpd:"
+ killproc afpd
+ RETVAL_AFPD=$?
+ echo
+ fi
+
+ if [ -x ${ATALK_SBIN}/cnid_metad ]; then
+ echo -n " Stopping cnid_metad:"
+ killproc cnid_metad
+ RETVAL_CNID_METAD=$?
+ echo
+ fi
+
+ if [ $RETVAL_AFPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 ] ; then
+ RETVAL=0
+ rm -f /var/lock/subsys/atalk || RETVAL=1
+ fi
+ echo ""
+ ;;
+ 'restart'|'reload')
+ $0 stop
+ $0 start
+ RETVAL=$?
+ ;;
+ 'status')
+ status cnid_metad
+ status afpd
+ RETVAL=$?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload|status}"
+ exit 2
esac
exit $RETVAL