#! /bin/sh


case "$1" in

    start)
	getcfg nfs_enable
        if [ "$?" != "1" ]; then
                echo "NFS  disable"
                exit 0
        fi
	echo "NFS server on"
	getcfg gen_exports
	/sbin/portmap	
	rpc.exportfs -rv
	rpc.nfsd 2
	rpc.mountd
	;;

    reload)
	getcfg gen_exports
	rpc.exportfs -rv
	;;

    stop)
	echo "NFS server down"
	
	killall -9 portmap 
	if [ "$?" = "0" ]; then echo "Done"
	else                    echo "FAILED"; fi
	
	killall -9 nfsd 
	if [ "$?" = "0" ]; then echo "Done"
	else                    echo "FAILED"; fi

	killall -9 rpc.mountd
	if [ "$?" = "0" ]; then echo "Done"
	else                    echo "FAILED"; fi
	;;

    restart)
    	$0 stop
	sleep 1
	$0 start
	;;

    *)
	echo "Usage: $0 (start|stop|restart)"
	exit 1
	;;

esac

exit 0

