-#! /bin/sh
+#! /bin/bash
# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
#
echo
}
-SYSCNF=/etc/sysconfig/afs
+SYSCNF=${SYSCNF:-/etc/sysconfig/afs}
+KERNEL_VERSION=`uname -r`
# Gather up options and post startup script name, if present
if [ -f $SYSCNF ] ; then
CACHEINFO=${CACHEINFO:-/usr/vice/etc/cacheinfo}
CACHE=${CACHEDIR:-/usr/vice/cache}
AFS=${AFSDIR:-/afs}
+AFSD=${AFSD:-/usr/vice/etc/afsd}
+BOSSERVER=${BOSSERVER:-/usr/afs/bin/bosserver}
+BOS=${BOS:-/usr/bin/bos}
+KILLAFS=${KILLAFS:-/usr/vice/etc/killafs}
# is_on returns 1 if value of arg is "on"
is_on() {
}
on_network() {
- ADDRS=`LANG=C ifconfig -a | grep 'inet addr' | grep -v 127.0.0.1 | wc -l`
+ if hash ip 2>/dev/null >/dev/null; then
+ IP="ip -4 addr"
+ elif hash ifconfg 2>/dev/null >/dev/null; then
+ IP="ifconfig -a"
+ else
+ echo afs: Unable to check interfaces. 1>&2
+ return 1
+ fi
+ ADDRS=`LANG=C ${IP} | grep 'inet ' | grep -v 127.0.0.1 | wc -l`
if [ "$ADDRS" = "" ]; then
echo afs: No interfaces with IP address 1>&2
return 1
esac
# For now, just use uname -r to get the module version.
- VERSION=`uname -r`
-
- LIBAFS=libafs-$VERSION$MP.o
+ case $KERNEL_VERSION in
+ [1-2].[0-5].*)
+ LIBAFS=libafs-$KERNEL_VERSION$MP.o
+ ;;
+ *)
+ LIBAFS=libafs-$KERNEL_VERSION$MP.ko
+ ;;
+ esac
}
#
# unregister_filesystem_Rsmp_b240cad8 is a typcial SMP version string from
# a kernel built from ftp.kernel.org
#
-
-KSYMS_FILE=/proc/ksyms
+case $KERNEL_VERSION in
+ [1-2].[0-5].*)
+ KSYMS_FILE=/proc/ksyms
+ ;;
+ *)
+ KSYMS_FILE=/proc/kallsyms
+ ;;
+esac
SEARCH_STR="unregister_filesystem"
DEFAULT_SMP_PREFIX="smp_" # Redhat kernels need "smp" instead
PREFIX="" # none needed for UP with <= 1Gig memory
h8="$h$h$h$h$h$h$h$h"
prefix_set=0
- set X `fgrep $SEARCH_STR $KSYMS_FILE 2> /dev/null`; shift
- str=$2
+ set X `egrep "\<$SEARCH_STR" $KSYMS_FILE 2> /dev/null`; shift
+
+ case $KERNEL_VERSION in
+ [1-2].[0-5].*)
+ str=$2
+ ;;
+ *)
+ str=$3
+ ;;
+ esac
case $str in
${SEARCH_STR}_R$h8)
# No prefix required
esac
}
-MODLOADDIR=/usr/vice/etc/modload
+MODLOADDIR=${MODLOADDIR:-/usr/vice/etc/modload}
# load_client loads the AFS client module if it's not already loaded.
load_client() {
# If LIBAFS is set, use it.
exit 1
fi
- # use the prefix command if required
- set_prefix
- /sbin/insmod ${PREFIX:+-P $PREFIX} -f -m $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+ # We need exportfs in order to access the cache files. Load it, but
+ # ignore errors as on some machines it may be built in to the kernel,
+ # not a module
+ /sbin/modprobe exportfs >/dev/null 2>&1
+
+ if [ -f $KSYMS_FILE ]; then
+ # use the prefix command if required
+ case $KERNEL_VERSION in
+ [1-2].[0-5].*)
+ set_prefix
+ /sbin/insmod ${PREFIX:+-P $PREFIX} -f -m $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+ ;;
+ *)
+ /sbin/insmod $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+ ;;
+ esac
+ else
+ /sbin/insmod $MODLOADDIR/$LIBAFS > $MODLOADDIR/libafs.map 2>&1
+ fi
}
generate_cacheinfo() {
if [ "$PART" = "NONE" ]; then
echo "$CACHE or /usr/vice is not a separate partition"
echo "you have to change the cachesize in $SYSCNF by hand"
- exit 1
+ echo "AFS will be started with a VERY small cache of 8Mb."
+ CACHESIZE=8000
else
- PARTSIZE=`echo $LINE | awk '{print $2}'`
+ # Check to see if df has pretty-printed for long dev (i.e. LVM)
+ FCHAR=`echo $LINE | cut -c 1`
+ if [ "$FCHAR" = "/" ]; then
+ PARTSIZE=`echo $LINE | awk '{print $2}'`
+ else
+ PARTSIZE=`echo $LINE | awk '{print $1}'`
+ fi
CACHESIZE=`echo $PARTSIZE | awk '{printf "%d",int(($1*.8)/1000)*1000}'`
fi
fi
case "$1" in
start)
if [ ! "$afs_rh" -o ! -f /var/lock/subsys/afs ]; then
- on_network || exit 1
+ if [ `echo "$OPTIONS" | grep -c dynroot` = 0 ]; then
+ on_network || exit 1
+ fi
# Load kernel extensions
if load_client ; then :
else
echo "Starting AFS services..... "
# Start bosserver, it if exists
- if is_on $AFS_SERVER && test -x /usr/afs/bin/bosserver ; then
- /usr/afs/bin/bosserver
+ if is_on $AFS_SERVER && test -x $BOSSERVER ; then
+ $BOSSERVER
test "$afs_rh" && touch /var/lock/subsys/afs
+ if is_on $WAIT_FOR_SALVAGE; then
+ # wait for fileserver to finish salvaging
+ sleep 10
+ while $BOS status localhost fs 2>&1 | grep 'Auxiliary.*salvaging'; do
+ echo "Waiting for salvager to finish..... "
+ sleep 10
+ done
+ fi
fi
# Start AFS client
- if is_on $AFS_CLIENT && test -x /usr/vice/etc/afsd ; then
+ if is_on $AFS_CLIENT && test -x $AFSD ; then
generate_cacheinfo
choose_afsdoptions
- /usr/vice/etc/afsd ${AFSD_OPTIONS}
+ $AFSD ${AFSD_OPTIONS}
test "$afs_rh" && touch /var/lock/subsys/afs
$AFS_POST_INIT
fi
echo "Stopping AFS services..... "
if is_on $AFS_CLIENT ; then
- if [ -x /usr/vice/etc/killafs ] ; then
- runcmd "Sending all processes using /afs the TERM signal ..." /usr/vice/etc/killafs TERM
- runcmd "Sending all processes using /afs the KILL signal ..." /usr/vice/etc/killafs KILL
+ if [ -x $KILLAFS ] ; then
+ runcmd "Sending all processes using /afs the TERM signal ..." $KILLAFS TERM
+ runcmd "Sending all processes using /afs the KILL signal ..." $KILLAFS KILL
fi
umount /afs
fi
- if is_on $AFS_SERVER && test -x /usr/bin/bos ; then
+ if is_on $AFS_SERVER && test -x $BOS ; then
echo "Stopping AFS bosserver"
- /usr/bin/bos shutdown localhost -localauth -wait
+ $BOS shutdown localhost -localauth -wait
killall -HUP bosserver
fi