Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > dd0486ded0790917ca0605ab8ec1479f > files > 9

openafs-1.4.7-5mdv2009.0.src.rpm

#!/bin/sh
# 
# chkconfig: 345 60 20
# description: Starts the AFS client daemon

### BEGIN INIT INFO
# Provides: openafs
# Required-Start: $network
# Required-Stop: $network
# Should-Start: dkms
# Default-Start: 345
# Short-Description: Starts the AFS client daemon
# Description: This startup script starts the AFS client daemon
### END INIT INFO

# Source function library
. /etc/rc.d/init.d/functions

# Source networking configuration
. /etc/sysconfig/network

# Source specific configuration if available
if [ -r /etc/sysconfig/openafs ] ; then
    . /etc/sysconfig/openafs
else
    CACHESIZE=262144
    MOUNTDIR=/mnt/afs
fi

# Check that networking is up, unless dynroot is activated
[ ${NETWORKING} = "no" -a $DYNROOT != "yes" ] && exit 0

NAME="AFS client daemon"
LOCKFILE=/var/lock/subsys/openafs

start() {
    rc=0
    if [ ! -f $LOCKFILE ]; then
	echo -n "Starting $NAME: "

	# generate cache info
        echo $MOUNTDIR:/var/cache/openafs:$CACHESIZE > /etc/openafs/cacheinfo

	# compute options
	OPTIONS="-mountdir $MOUNTDIR"

	if [ $DYNROOT = "yes" ]; then
	    OPTIONS="$OPTIONS -dynroot"
	fi

	if [ $AUTO_OPTIONS = "yes" ]; then
	    if [ $CACHESIZE -lt 131072 ]; then
		OPTIONS="$OPTIONS -stat 300 -dcache 100 -daemons 2 -volumes 50"
	    elif [ $CACHESIZE -lt 524288 ]; then
		OPTIONS="$OPTIONS -stat 2000 -dcache 800 -daemons 3 -volumes 70"
	    elif [ $CACHESIZE -lt 1048576 ]; then
		OPTIONS="$OPTIONS -stat 2800 -dcache 2400 -daemons 5 -volumes 128"
	    elif [ $CACHESIZE -lt 2097152 ]; then
		OPTIONS="$OPTIONS -stat 3600 -dcache 3600 -daemons 5 -volumes 196 -files 50000"
	    else
		OPTIONS="$OPTIONS -stat 4000 -dcache 4000 -daemons 6 -volumes 256 -files 50000"
	    fi
	fi

	if [ -n $MORE_OPTIONS ]; then
	    OPTIONS="$OPTIONS $MORE_OPTIONS"
	fi

	# load kernel module
	modprobe libafs

	# start daemon
	daemon "afsd $OPTIONS >/dev/null 2>&1"
	rc=$?
	echo
	[ $rc -eq 0 ] && touch $LOCKFILE
    fi
    return $rc
}

stop() {
    echo -n "Stopping $NAME: "

    # unmount file system
    umount $MOUNTDIR
    rc=$?
    if [ $rc -eq 0 ]; then
	success
	echo
    else
	failure
	echo
	return $rc
    fi

    # unload kernel module
    rmmod libafs

    rm -f $LOCKFILE
    return $rc
}

restart() {
    stop
    start
}

case $1 in 
    start)
	start
	;;
    stop)
	stop
	;;
    restart)
	restart
	;;
    condrestart)
	if [ -f $LOCKFILE ]; then
	    restart
	fi
	;;
    status)
	status afsd
	;;
    *)
	echo "Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
	;;
esac

exit $?