# directory or online at http://www.openafs.org/dl/license10.html
#
# Portions Copyright (c) 2003 Apple Computer, Inc.
+#
+# Updated to match standard service scripts
+# Phil Holland <hollandp@umich.edu> 6/11/04
. /etc/rc.common
-CheckForNetwork
-
-if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi
+#
+# Variable Definition Section
+#
+CheckForNetwork
+VICEETC=/usr/vice/etc
+AFSD=$VICEETC/afsd
if [ -r /var/db/openafs ]; then
- VICEETC=/var/db/openafs/etc
- AFSD=/usr/sbin/afsd
-else
- VICEETC=/usr/vice/etc
- AFSD=$VICEETC/afsd
+ VICEETC=/var/db/openafs/etc
+ AFSD=/usr/sbin/afsd
fi
+
CONFIG=$VICEETC/config
AFSDOPT=$CONFIG/afsd.options
PACKAGE=$CONFIG/package.options
MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
-if [ -f $AFSDOPT ]; then
- OPTIONS=`cat $AFSDOPT`
-else
- OPTIONS="$MEDIUM -fakestat"
-fi
+if [ -x /usr/sbin/kextstat ]; then KMODSTAT=/usr/sbin/kextstat; fi
+if [ -x /usr/sbin/kmodstat ]; then KMODSTAT=/usr/sbin/kmodstat; fi
-if [ -x /usr/sbin/kmodstat ]; then
- KMODSTAT=/usr/sbin/kmodstat
-else
- if [ -x /usr/sbin/kextstat ]; then
- KMODSTAT=/usr/sbin/kextstat
-fi
-fi
+
+StartService()
+{
+ echo "Starting OpenAFS"
+
+ if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi
+
+ if [ -f $AFSDOPT ]; then
+ OPTIONS=`cat $AFSDOPT`
+ else
+ OPTIONS="$MEDIUM -fakestat"
+ fi
# Need the commands ps, awk, kill, sleep
-PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
-if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
-:
-else
-if [ -d $VICEETC/afs.kext ]; then
+ PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
+
+ if [ -d $VICEETC/afs.kext ]; then
echo "Loading AFS kernel extensions"
kextload $VICEETC/afs.kext
-else
+ else
echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
exit 1
-fi
-fi
-if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
-:
-else
- echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
+ fi
+
+ if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
+ :
+ else
+ echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
exit 1
-fi
+ fi
#
# Start the AFS server processes if a bosserver exists
#
-if [ -x /usr/afs/bin/bosserver ]; then
+ if [ -x /usr/afs/bin/bosserver ]; then
echo "Starting AFS Server processes"
/usr/afs/bin/bosserver
OPTIONS="$OPTIONS -nosettime"
sleep 30
-fi
+ fi
#
# Check that all of the client configuration files exist
#
-for file in $AFSD $VICEETC/cacheinfo \
- $VICEETC/ThisCell $VICEETC/CellServDB
-do
- if [ ! -f ${file} ]; then
- echo "${file} does not exist. Not starting AFS client."
- exit 1
- fi
-done
+ for file in $AFSD $VICEETC/cacheinfo \
+ $VICEETC/ThisCell $VICEETC/CellServDB
+ do
+ if [ ! -f ${file} ]; then
+ echo "${file} does not exist. Not starting AFS client."
+ exit 1
+ fi
+ done
#
# Check that the root directory for AFS (/afs)
# and the cache directory (/usr/vice/cache) both exist
#
-for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
-do
- if [ ! -d ${dir} ]; then
- echo "${dir} does not exist. Not starting AFS client."
- exit 2
- fi
-done
+ for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
+ do
+ if [ ! -d ${dir} ]; then
+ echo "${dir} does not exist. Not starting AFS client."
+ exit 2
+ fi
+ done
-echo "Starting afsd"
-$AFSD $OPTIONS
+ echo "Starting afsd"
+ $AFSD $OPTIONS
#
# Call afssettings (if it exists) to set customizable parameters
#
-if [ -x $VICEETC/config/afssettings ]; then
- sleep 2
- $VICEETC/config/afssettings
-fi
+ if [ -x $CONFIG/afssettings ]; then
+ sleep 2
+ $CONFIG/afssettings
+ fi
#
# Run package to update the disk
#
-if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
+ if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
/usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
-case $? in
-0)
- (echo "Package completed successfully") > /dev/console 2>&1
- date > /dev/console 2>&1
- ;;
-4)
- (echo "Rebooting to restart system") > /dev/console 2>&1
- sync
- /sbin/reboot
- ;;
-*)
- (echo "Package update failed; continuing") > /dev/console 2>&1
- ;;
-esac
-
-fi
+ case $? in
+ 0)
+ (echo "Package completed successfully") > /dev/console 2>&1
+ date > /dev/console 2>&1
+ ;;
+ 4)
+ (echo "Rebooting to restart system") > /dev/console 2>&1
+ sync
+ /sbin/reboot
+ ;;
+ *)
+ (echo "Package update failed; continuing") > /dev/console 2>&1
+ ;;
+ esac
+ fi
#
# Start AFS inetd services
# (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
#
-if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
- /usr/sbin/inetd.afs /etc/inetd.conf.afs
-fi
+ if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
+ /usr/sbin/inetd.afs /etc/inetd.conf.afs
+ fi
+}
+
+StopService()
+{
+ echo "Stopping AFS"
+
+ if $KMODSTAT | perl -e 'exit not grep /openafs/, <>' ; then
+ echo "Unmounting /afs"
+ umount -f /afs 2>&1 > /dev/console
+
+ echo "Shutting down afsd processes"
+ $AFSD -shutdown 2>&1 > /dev/console
+
+ echo "Unloading AFS kernel extensions"
+ kextunload $VICEETC/afs.kext 2>&1 > /dev/console
+ fi
+}
+
+RestartService()
+{
+ StopService
+ StartService
+}
+
+RunService "$1"