5 kx #!/bin/sh
5 kx # rc.rpc: start/stop/restart RPC daemons needed to use NFS.
5 kx #
5 kx # You must run these daemons in order to mount NFS partitions
5 kx # (unless you use the mount option '-o nolock', which can
5 kx # corrupt files and is not generally recommended unless you
5 kx # are mounting the partition(s) as read-only).
5 kx #
5 kx # To run an NFS server, starting these is mandatory.
5 kx #
5 kx
5 kx # Source default settings:
5 kx if [ -r /etc/default/rpc ]; then
5 kx . /etc/default/rpc
5 kx fi
5 kx
5 kx rpc_start() {
5 kx if [ -x /sbin/rpcbind -a -x /sbin/rpc.statd ]; then
5 kx # Set up port for lockd:
5 kx if [ -n "$LOCKD_TCP_PORT" ]; then
5 kx /sbin/sysctl -w "fs.nfs.nlm_tcpport=$LOCKD_TCP_PORT" >/dev/null 2>&1
5 kx fi
5 kx if [ -n "$LOCKD_UDP_PORT" ]; then
5 kx /sbin/sysctl -w "fs.nfs.nlm_udpport=$LOCKD_UDP_PORT" >/dev/null 2>&1
5 kx fi
5 kx if ! ps axc | grep -q rpcbind ; then
5 kx echo "Starting RPC portmapper: /sbin/rpcbind -l $* $RPCBIND_OPTS"
5 kx /sbin/rpcbind -l "$@" $RPCBIND_OPTS
5 kx fi
5 kx if ! ps axc | grep -q rpc.statd ; then
5 kx if [ -n "$RPC_STATD_HOSTNAME" ]; then
5 kx RPC_STATD_OPTS="$RPC_STATD_OPTS -n $RPC_STATD_HOSTNAME"
5 kx fi
5 kx if [ -n "$RPC_STATD_PORT" ]; then
5 kx RPC_STATD_OPTS="$RPC_STATD_OPTS -p $RPC_STATD_PORT"
5 kx fi
5 kx if [ -n "$RPC_STATD_OUTGOING_PORT" ]; then
5 kx RPC_STATD_OPTS="$RPC_STATD_OPTS -o $RPC_STATD_OUTGOING_PORT"
5 kx fi
5 kx echo "Starting RPC NSM (Network Status Monitor): /sbin/rpc.statd $RPC_STATD_OPTS"
5 kx /sbin/rpc.statd $RPC_STATD_OPTS
5 kx fi
5 kx else
5 kx echo "WARNING: Cannot start RPC daemons needed for NFS. One or more of"
5 kx echo " these required daemons is not executable or is not present"
5 kx echo " on your system:"
5 kx echo
5 kx echo " /sbin/rpcbind or /sbin/rpc.statd"
5 kx echo
5 kx fi
5 kx }
5 kx
5 kx rpc_stop() {
5 kx killall rpc.statd 2> /dev/null
5 kx sleep 1
5 kx killall rpcbind 2> /dev/null
5 kx sleep 1
5 kx killall -9 rpc.statd 2> /dev/null # make sure :)
5 kx sleep 1
5 kx killall -9 rpcbind 2> /dev/null # make sure :)
5 kx sleep 1
5 kx }
5 kx
5 kx rpc_restart() {
5 kx rpc_stop
5 kx rpc_start
5 kx }
5 kx
5 kx case "$1" in
5 kx 'start')
5 kx # Warm restart by default (see "man rpcbind" for details about the -w option)
5 kx rpc_start -w
5 kx ;;
5 kx 'cold_start') # Start without -w option
5 kx rpc_start
5 kx ;;
5 kx 'stop')
5 kx rpc_stop
5 kx ;;
5 kx 'restart')
5 kx rpc_restart
5 kx ;;
5 kx *)
5 kx echo "usage $0 start|stop|restart"
5 kx esac