#!/bin/sh DAEMON=nfsd DAEMON_CHECK="portmap nfsd mountd" . /etc/init.d/modlibrc PROCNFSD_DIR=/proc/fs/nfsd start() { set -o noglob echo -n 'Starting nfsd ... ' if [ ! -e /etc/exports ]; then echo "can't open /etc/exports ... failed." exit 1 fi modprobe nfsd > /dev/null 2>&1 # Fill /proc/fs/nfsd mount -t nfsd nfsd $PROCNFSD_DIR > /dev/null 2>&1 # set max rsize/wsize supported by server to 64kb [ -e $PROCNFSD_DIR/max_block_size ] && echo 65536 > $PROCNFSD_DIR/max_block_size local NFS_DIR=/var/lib/nfs mkdir -p $NFS_DIR for file in etab rmtab xtab; do touch $NFS_DIR/$file done /usr/sbin/portmap exitval1=$? /usr/sbin/exportfs -r > /dev/null 2>&1 exitval2=$? /usr/sbin/nfsd exitval3=$? /usr/sbin/mountd exitval4=$? if [ "$exitval1" -eq 0 ] && [ "$exitval2" -eq 0 ] \ && [ "$exitval3" -eq 0 ] && [ "$exitval4" -eq 0 ]; then echo 'done.' else echo 'failed.' return 1 fi } stop() { killall mountd >/dev/null 2>&1 exitval1=$? killall -9 nfsd > /dev/null 2>&1 exitval2=$? /usr/sbin/exportfs -au exitval3=$? killall portmap > /dev/null 2>&1 exitval4=$? umount $PROCNFSD_DIR > /dev/null 2>&1 [ "$exitval1" -eq 0 -a "$exitval2" -eq 0 -a "$exitval3" -eq 0 -a "$exitval4" -eq 0 ] && return 0 } reload() { /usr/sbin/exportfs -r > /dev/null 2>&1 } case $1 in ""|load) [ -d "/tmp/flash/nfsd" ] || mkdir -p /tmp/flash/nfsd ln -fs /tmp/flash/nfsd/exports /var/tmp/exports # portmap needs this modlib_addgroup nobody modlib_adduser nobody -s /bin/false -D -S -H -G nobody -g 'nobody' modreg cgi 'nfsd' 'NFS-Server' modreg daemon $DAEMON modreg file nfsd hosts_allow 'hosts.allow' 1 "hosts_allow" modreg file nfsd hosts_deny 'hosts.deny' 1 "hosts_deny" modreg file nfsd exports 'exports' 1 "exports" modlib_start $NFSD_ENABLED ;; unload) modunreg file nfsd modunreg daemon $DAEMON modunreg cgi nfsd modlib_stop rmmod nfsd lock sunrpc exportfs > /dev/null 2>&1 ;; start) modlib_start ;; stop) modlib_stop ;; reload) modlib_reload ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|reload|status]" 1>&2 exit 1 ;; esac exit 0