Sophie

Sophie

distrib > Mandriva > 2007.1 > x86_64 > by-pkgid > ec1353c51cf2bd4d46fb842cdb5d4cdc > files > 36

nfs-utils-1.0.12-13mdv2007.1.src.rpm

#!/bin/bash
#
# rpcgssd       Start up and shut down RPCSEC GSS daemon
#
# chkconfig: 345 19 69
# description: Starts user-level daemon that manages RPCSEC GSS contexts \
#	       for the NFSv4 client.
#
#
### BEGIN INIT INFO
# Provides: rpcgssd
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: RPCSEC GSS daemon
# Description: Starts user-level daemon that manages RPCSEC GSS contexts
#	       for the NFSv4 client.
### END INIT INFO

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

# Check for and source configuration file otherwise set defaults
NAME=rpc.gssd
BINARY=$NAME
LOCKFILE=/var/lock/subsys/$NAME
SECURE_NFS_MODS="des rpcsec_gss_krb5"
RPCGSSD_OPTIONS="-m"
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs

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

	# Load sunrpc which mounts the rpc_pipes fs.
	if [ -x /sbin/lsmod -a -x /sbin/modprobe ]; then
	    if ! /sbin/lsmod | grep sunrpc > /dev/null ; then
		/sbin/modprobe sunrpc || exit 1
	    fi
	    # Load rpcsec modules
	    for i in $SECURE_NFS_MODS; do
		if ! /sbin/lsmod | grep $i > /dev/null ;  then
		    /sbin/modprobe $i || exit 1
		fi
	    done
	fi

	# Make sure the mount worked.
	if [ -z "$RPCMTAB" ]; then
	    RPCMTAB=`awk '{ if ($3 ~ /^rpc_pipefs$/ ) print $2}' /proc/mounts`
	    if [ -z "$RPCMTAB" ]; then
		echo "Error: RPC MTAB does not exist."
		exit 1
	    fi
	fi

	# Start daemon.
	daemon $BINARY $RPCGSSD_OPTIONS
	res=$?
	echo
	[ $res -eq 0 ] && touch $LOCKFILE
    fi
    return $res
}

stop () {
    # Stop daemon.
    echo -n "Stopping $NAME:"
    killproc $BINARY
    res=$?
    echo
    [ $res -eq 0 ] && rm -f $LOCKFILE
    return $res
}

reload() {
    echo -n "Reloading $NAME: "
    killproc $BINARY -HUP
    res=$?
    echo
    return $res
}


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

exit $?