summaryrefslogtreecommitdiffstats
path: root/source/n/nfs-utils/rc.nfsd
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2009-08-26 10:00:38 -0500
committer Eric Hameleers <alien@slackware.com>2018-05-31 22:41:17 +0200
commit5a12e7c134274dba706667107d10d231517d3e05 (patch)
tree55718d5acb710fde798d9f38d0bbaf594ed4b296 /source/n/nfs-utils/rc.nfsd
downloadcurrent-5a12e7c134274dba706667107d10d231517d3e05.tar.gz
current-5a12e7c134274dba706667107d10d231517d3e05.tar.xz
Slackware 13.0slackware-13.0
Wed Aug 26 10:00:38 CDT 2009 Slackware 13.0 x86_64 is released as stable! Thanks to everyone who helped make this release possible -- see the RELEASE_NOTES for the credits. The ISOs are off to the replicator. This time it will be a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We're taking pre-orders now at store.slackware.com. Please consider picking up a copy to help support the project. Once again, thanks to the entire Slackware community for all the help testing and fixing things and offering suggestions during this development cycle. As always, have fun and enjoy! -P.
Diffstat (limited to 'source/n/nfs-utils/rc.nfsd')
-rw-r--r--source/n/nfs-utils/rc.nfsd98
1 files changed, 98 insertions, 0 deletions
diff --git a/source/n/nfs-utils/rc.nfsd b/source/n/nfs-utils/rc.nfsd
new file mode 100644
index 000000000..f21133829
--- /dev/null
+++ b/source/n/nfs-utils/rc.nfsd
@@ -0,0 +1,98 @@
+#!/bin/sh
+# Start/stop/restart the NFS server.
+#
+# This is an init script for the knfsd NFS daemons.
+# To use NFS, you must first set up /etc/exports.
+# See exports(5) for information on /etc/exports format.
+#
+# Written for Slackware Linux by Patrick J. Volkerding <volkerdi@slackware.com>.
+
+nfsd_start() {
+ # Sanity checks. Exit if there's no /etc/exports, or if there aren't any
+ # shares defined in it.
+ if [ ! -r /etc/exports ]; then # no config file, exit:
+ exit
+ elif ! grep -v '^#' /etc/exports | grep '/' 1> /dev/null 2> /dev/null ; then
+ exit # no uncommented shares in /etc/exports
+ fi
+
+ # First, make sure the nfsd kernel module is loaded. You can comment this
+ # part out if you've built nfsd support directly into the kernel.
+ if [ -z "`/sbin/lsmod | grep "^nfsd "`" ]; then
+ /sbin/modprobe nfsd
+ fi
+
+ # For kernels newer than 2.4.x, use the new way of handling nfs client requests.
+ if [ ! "$(/bin/uname -r | /bin/cut -f 1,2 -d .)" = "2.4" ]; then
+ if grep -wq nfsd /proc/filesystems 2> /dev/null ; then
+ if grep -vwq nfsd /proc/mounts 2> /dev/null ; then
+ /sbin/mount -t nfsd nfsd /proc/fs/nfs 2> /dev/null
+ fi
+ fi
+ fi
+
+ # If basic RPC services are not running, start them:
+ if ! ps axc | grep -q rpc.statd ; then
+ if [ -r /etc/rc.d/rc.rpc ]; then
+ sh /etc/rc.d/rc.rpc start
+ else
+ # Sure, we tested for rpc.statd, but this is the probable cause:
+ echo "FATAL: Can't start NFS server without portmap package."
+ sleep 5
+ exit 1
+ fi
+ fi
+
+ echo "Starting NFS server daemons:"
+
+ if [ -x /usr/sbin/exportfs ]; then
+ echo " /usr/sbin/exportfs -r"
+ /usr/sbin/exportfs -r
+ fi
+
+ if [ -x /usr/sbin/rpc.rquotad ]; then
+ echo " /usr/sbin/rpc.rquotad"
+ /usr/sbin/rpc.rquotad
+ fi
+
+ # Start 8 nfsd servers by default (an old Sun standard):
+ if [ -x /usr/sbin/rpc.nfsd ]; then
+ echo " /usr/sbin/rpc.nfsd 8"
+ /usr/sbin/rpc.nfsd 8
+ fi
+
+ if [ -x /usr/sbin/rpc.mountd ]; then
+ echo " /usr/sbin/rpc.mountd"
+ /usr/sbin/rpc.mountd
+ fi
+
+}
+
+nfsd_stop() {
+ killall rpc.mountd 2> /dev/null
+ killall nfsd 2> /dev/null
+ sleep 1
+ killall -9 nfsd 2> /dev/null # make sure :)
+ killall rpc.rquotad 2> /dev/null
+ /usr/sbin/exportfs -au 2> /dev/null
+}
+
+nfsd_restart() {
+ nfsd_stop
+ sleep 1
+ nfsd_start
+}
+
+case "$1" in
+'start')
+ nfsd_start
+ ;;
+'stop')
+ nfsd_stop
+ ;;
+'restart')
+ nfsd_restart
+ ;;
+*)
+ echo "usage $0 start|stop|restart"
+esac