#!/bin/sh
#
# code by ngc1927
#
export PATH=$PATH:.:/var/bin:/var/sbin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.:/var/lib
# set modules path
MODULES="/var/lib/modules/"
# set server start
SERVER="4"

cd /tmp/

# load modules ..if not
check=`lsmod | grep -c "^exportfs"`
if [ -r $MODULES/exportfs.ko ] && [ $check = 0 ]; then
	insmod $MODULES/exportfs.ko
	echo "..module exportfs loaded"
fi

check=`lsmod | grep -c "^nfsd"`
if [ -r $MODULES/nfsd.ko ] && [ $check = 0 ]; then
	insmod $MODULES/nfsd.ko
	echo "..module nfsd loaded"
fi
# start programs
start-stop-daemon --start --quiet --exec /var/sbin/rpc.portmap
sleep 2
start-stop-daemon --start --quiet --exec /var/sbin/rpc.mountd
sleep 1
start-stop-daemon --start --quiet --exec /var/sbin/rpc.statd
sleep 1
/var/sbin/exportfs -r
sleep 1
start-stop-daemon --start --quiet --exec /var/sbin/rpc.nfsd $SERVER

# copy file for autostart at reboot
[ ! -e /var/etc/rcS.d/S80nfsd_start.sh ] && cp -a /var/etc/SifTeam/bin/S80nfsd_start.sh /var/etc/rcS.d/

echo "*****************"
echo "NFSD Started"

exit 0
