#!/bin/bash # source application-specific settings [ -f /etc/conf.d/nfs ] && . /etc/conf.d/nfs . /etc/rc.conf . /etc/rc.d/functions DAEMON_NAME=nfsd #RQUOTAD_PID=`pidof -o %PPID /usr/sbin/rpc.rquotad` NFSD_PID=`pidof -o %PPID nfsd` MOUNTD_PID=`pidof -o %PPID /usr/sbin/rpc.mountd` case "$1" in start) stat_busy "Starting $DAEMON_NAME" # This is the new "kernel 2.6 way" to handle the exports file if grep -qs nfsd /proc/filesystems ; then if ! grep -qs "^nfsd[[:space:]]/proc/fs/nfsd[[:space:]]" /proc/mounts ; then mount -t nfsd nfsd /proc/fs/nfsd fi fi /usr/sbin/exportfs -r if [ ! -f /var/run/daemons/portmap ]; then echo "ERROR: portmap is not running" stat_fail exit 1 fi if [ ! -f /var/run/daemons/nfslock ]; then stat_fail echo "ERROR: nfslock is not running" exit 1 fi #[ -z "$RQUOTAD_PID" ] && /usr/sbin/rpc.rquotad $RQUOTAD_OPTS #if [ $? -gt 0 ]; then # stat_fail # exit 1 #else # echo `pidof -o %PPID /usr/sbin/rpc.rquotad` > /var/run/rpc.rquotad.pid #fi [ -z "$NFSD_PID" ] && /usr/sbin/rpc.nfsd $NFSD_OPTS if [ $? -gt 0 ]; then stat_fail exit 1 else echo `pidof -o %PPID nfsd` > /var/run/rpc.nfsd.pid fi [ -z "$MOUNTD_PID" ] && /usr/sbin/rpc.mountd $MOUNTD_OPTS if [ $? -gt 0 ]; then stat_fail exit 1 else echo `pidof -o %PPID /usr/sbin/rpc.mountd` > /var/run/rpc.mountd.pid fi add_daemon $DAEMON_NAME stat_done ;; stop) stat_busy "Stopping $DAEMON_NAME" [ ! -z "$MOUNTD_PID" ] && kill $MOUNTD_PID &> /dev/null if [ $? -gt 0 ]; then stat_fail exit 1 else rm /var/run/rpc.mountd.pid &> /dev/null fi sleep 1 [ ! -z "$NFSD_PID" ] && kill $NFSD_PID &> /dev/null if [ $? -gt 0 ]; then stat_fail exit 1 else kill -9 $NFSD_PID &> /dev/null rm /var/run/rpc.nfsd.pid &> /dev/null fi #[ ! -z "$RQUOTAD_PID" ] && kill $RQUOTAD_PID &> /dev/null #if [ $? -gt 0 ]; then # stat_fail # exit 1 #else # kill -9 $RQUOTAD_PID &> /dev/null # rm /var/run/rpc.rquotad.pid #fi if [ "$RUNLEVEL" = "0" ]; then /usr/sbin/exportfs -au fi rm_daemon $DAEMON_NAME stat_done ;; reload) /usr/sbin/exportfs -au ;; restart) $0 stop sleep 2 $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac exit 0