cvsdist 9e6d913
#!/bin/bash
cvsdist 9e6d913
#
cvsdist 9e6d913
# rpcsvcgssd    Start up and shut down RPCSEC GSS daemon
cvsdist 9e6d913
#
5b1bacb
# chkconfig: - 31 69
cvsdist 9e6d913
# description: Starts user-level daemon that manages RPCSEC GSS contexts \
0ce3b8d
#	       for the NFS server.
0ce3b8d
0ce3b8d
### BEGIN INIT INFO
0ce3b8d
# Provides: rpcsvcgssd
0ce3b8d
# Required-Start: $network $syslog
0ce3b8d
# Required-Stop: $network $syslog
0ce3b8d
# Default-Stop: 0 1 6
0ce3b8d
# Short-Description: Starts the RPCSEC GSS server daemon
0ce3b8d
# Description: NFS is a popular protocol for file sharing across \
0ce3b8d
#          networks. This deamon manages RPCSEC GSS contexts on the
0ce3b8d
#          server used by secure NFS mounts
0ce3b8d
### END INIT INFO
cvsdist 9e6d913
cvsdist 9e6d913
# Source function library.
cvsdist 9e6d913
. /etc/init.d/functions
cvsdist 9e6d913
cvsdist 9e6d913
# Source networking configuration.
adb2afe
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
cvsdist 9e6d913
cvsdist 9e6d913
# Check for and source configuration file otherwise set defaults
cvsdist 9e6d913
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
cvsdist 9e6d913
cvsdist 9e6d913
RETVAL=0
cvsdist 9e6d913
prog="rpc.svcgssd"
2d0e0c3
LOCKFILE=/var/lock/subsys/$prog
2d0e0c3
uid=`id | cut -d\( -f1 | cut -d= -f2`
cvsdist 9e6d913
cvsdist 9e6d913
case "$1" in
cvsdist 9e6d913
  start|condstart)
adb2afe
	# Check that networking is up.
adb2afe
	[ "${NETWORKING}" != "yes" ] && exit 6
adb2afe
	[ "${SECURE_NFS}" != "yes" ] && exit 6
adb2afe
	[ ! -x /usr/sbin/rpc.svcgssd ] && exit 5
2d0e0c3
	# Only root can start the service
2d0e0c3
	[ $uid -ne 0 ] && exit 4
adb2afe
cvsdist 9e6d913
	# Make sure the daemon is not already running.
cvsdist 9e6d913
	if status $prog > /dev/null ; then
cvsdist 9e6d913
		exit 0
cvsdist 9e6d913
	fi
ba86d89
	rm -f $LOCKFILE
cvsdist 9e6d913
3f418c2
	echo -n $"Starting RPC svcgssd: "
adb2afe
	# List of kernel modules to load
adb2afe
	[ -z "${SECURE_NFS_MODS}" ] && SECURE_NFS_MODS="des rpcsec_gss_krb5"
adb2afe
cvsdist 9e6d913
cafae3a
	# Make sure the rpc_pipefs filesystem is available
cafae3a
	[ "${RPCMTAB}" != "noload" ] && {
cafae3a
		RPCMTAB=`grep -v '^#' /proc/mounts | \
cafae3a
			awk '{ if ($3 ~ /^rpc_pipefs$/ ) print $2}'`
cafae3a
		[ -z "${RPCMTAB}" ] && {
cafae3a
			[ -x /sbin/lsmod -a -x /sbin/modprobe ] && {
cafae3a
				if ! /sbin/lsmod | grep sunrpc > /dev/null ; then
cafae3a
				 	/sbin/modprobe sunrpc
cafae3a
				fi
cafae3a
			}
cafae3a
			RPCMTAB=`grep -v '^#' /proc/mounts | \
cafae3a
				awk '{ if ($3 ~ /^rpc_pipefs$/ ) print $2}'`
cafae3a
			[ -z "${RPCMTAB}" ] && { \
cafae3a
				echo "Error: RPC MTAB does not exist."
cafae3a
				exit 6
cafae3a
			}
cafae3a
		}
cafae3a
	}
cafae3a
	[ "${SECURE_NFS_MODS}" != "noload" ] && {
cafae3a
		[ -x /sbin/lsmod -a -x /sbin/modprobe ] && {
3f418c2
		# Load rpcsec modules
cafae3a
			for i in ${SECURE_NFS_MODS}
cafae3a
			do 
cafae3a
				if ! /sbin/lsmod | grep $i > /dev/null ;  then
cafae3a
				 	/sbin/modprobe $i || {
cafae3a
						echo "Error: Unable to load '$i' security module."
cafae3a
						exit 6;
cafae3a
					}
cafae3a
				fi
cafae3a
			done
cafae3a
		}
cvsdist 9e6d913
	}
cvsdist 9e6d913
cvsdist 9e6d913
	# Start daemon.
48d9c62
	daemon $prog ${RPCSVCGSSDARGS}
cvsdist 9e6d913
	RETVAL=$?
cvsdist 9e6d913
	echo
ba86d89
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
cvsdist 9e6d913
	;;
cvsdist 9e6d913
  stop)
510c264
	# Just exit if not configured
510c264
	[ "${SECURE_NFS}" != "yes" ] && exit 6
510c264
2d0e0c3
	# Only root can stop the service
2d0e0c3
	[ $uid -ne 0 ] && exit 4
2d0e0c3
cvsdist 9e6d913
	# Stop daemon.
3f418c2
	echo -n $"Shutting down RPC svcgssd: "
cvsdist 9e6d913
	killproc $prog
cvsdist 9e6d913
	RETVAL=$?
cvsdist 9e6d913
	echo
0c53dbc
	rm -f $LOCKFILE
cvsdist 9e6d913
	;;
cvsdist 9e6d913
  status)
cvsdist 9e6d913
	status rpc.svcgssd
cvsdist 9e6d913
	RETVAL=$?
cvsdist 9e6d913
	;;
2d0e0c3
  restart|reload|force-reload)
cvsdist 9e6d913
	$0 stop
cvsdist 9e6d913
	$0 start
cvsdist 9e6d913
	RETVAL=$?
cvsdist 9e6d913
	;;
2d0e0c3
  condrestart|try-restart)
ba86d89
	if [ -f $LOCKFILE ]; then
cvsdist 9e6d913
		$0 restart
cvsdist 9e6d913
		RETVAL=$?
cvsdist 9e6d913
	fi
cvsdist 9e6d913
	;;
1ae9fb3
  condstop)
1ae9fb3
	if [ -f $LOCKFILE ]; then
1ae9fb3
		$0 stop
1ae9fb3
		RETVAL=$?
1ae9fb3
	fi
1ae9fb3
	;;
cvsdist 9e6d913
  *)
2d0e0c3
	echo $"Usage: $0 {start|stop|restart|force-reload|condstart|condrestart|try-restart|status|condstop}"
2d0e0c3
	RETVAL=2
cafae3a
	;;
cvsdist 9e6d913
esac
cvsdist 9e6d913
cvsdist 9e6d913
exit $RETVAL