--- /tmp/openafs-client-old 2005-11-13 18:06:46.000000000 +0100 +++ openafs-client 2005-12-23 10:29:46.000000000 +0100 @@ -10,22 +10,22 @@ choose_afsdoptions() { CACHESIZE=$(cut -d ':' -f 3 /etc/openafs/cacheinfo) - if [ -z "$OPTIONS" -o "$OPTIONS" = "AUTOMATIC" ]; then - if [ $CACHESIZE -lt 131072 ]; then + if [[ -z "$OPTIONS" || "$OPTIONS" = "AUTOMATIC" ]]; then + if [[ $CACHESIZE -lt 131072 ]]; then OPTIONS=$SMALL - elif [ $CACHESIZE -lt 524288 ]; then + elif [[ $CACHESIZE -lt 524288 ]]; then OPTIONS=$MEDIUM - elif [ $CACHESIZE -lt 1048576 ]; then + elif [[ $CACHESIZE -lt 1048576 ]]; then OPTIONS=$LARGE - elif [ $CACHESIZE -lt 2097152 ]; then + elif [[ $CACHESIZE -lt 2097152 ]]; then OPTIONS=$XLARGE else OPTIONS=$XXLARGE fi fi AFSD_OPTIONS="$OPTIONS $VERBOSE" - [ "$ENABLE_AFSDB" = "yes" ] && AFSD_OPTIONS="$AFSD_OPTIONS -afsdb" - [ "$ENABLE_DYNROOT" = "yes" ] && AFSD_OPTIONS="$AFSD_OPTIONS -dynroot" + [[ "$ENABLE_AFSDB" = "yes" ]] && AFSD_OPTIONS="$AFSD_OPTIONS -afsdb" + [[ "$ENABLE_DYNROOT" = "yes" ]] && AFSD_OPTIONS="$AFSD_OPTIONS -dynroot" } start() { @@ -38,34 +38,47 @@ if pgrep -u 0 afsd &> /dev/null; then eerror "afsd already running, not attempting to restart" eend 1 - elif [ ! -f /lib/modules/$(uname -r)/kernel/fs/openafs/openafs.ko ]; then - eerror "OpenAFS kernel module not found, please re-emerge openafs-kernel" - eend 1 - else - ebegin "Loading OpenAFS kernel module" + elif [[ -d /proc/fs/openafs ]]; then + ewarn "OpenAFS already active, trying to unload module" if ! modprobe -r openafs; then eerror "OpenAFS kernel module was loaded, unloading failed" eend 1 - elif ! modprobe openafs; then - eerror "Failed cleanly (re)loading the afs kernel module" - eend 1 else - eend 0 - ebegin "Starting OpenAFS daemon" - choose_afsdoptions - /usr/sbin/afsd ${AFSD_OPTIONS} &> /dev/null + cleanstart failed=$? eend $failed fi + else + cleanstart + failed=$? + eend $failed fi eoutdent - if [ $failed != 0 ]; then + if [[ $failed != 0 ]]; then return 1 fi } +cleanstart() +{ + ebegin "Loading OpenAFS kernel module" + if ! modprobe openafs; then + eerror "Failed loading the afs kernel module" + eend 1 + return 1 + else + eend 0 + ebegin "Starting OpenAFS daemon" + choose_afsdoptions + /usr/sbin/afsd ${AFSD_OPTIONS} &> /dev/null + failed=$? + eend $failed + return $failed + fi +} + stop() { ebegin "Stopping OpenAFS client" failed=1 @@ -83,7 +96,7 @@ failed=$? eend $failed - if [ $failed = 0 ]; then + if [[ $failed = 0 ]]; then ebegin "Unloading OpenAFS module" modprobe -r openafs failed=$? @@ -93,7 +106,7 @@ eoutdent - if [ $failed != 0 ]; then + if [[ $failed != 0 ]]; then return 1 fi }