diff options
author | John Bowler <jbowler@nslu2-linux.org> | 2005-07-10 05:42:42 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2005-07-10 05:42:42 +0000 |
commit | 2f95043c7a1f6bad0fddcd93653eb59feea32302 (patch) | |
tree | 5e9e44362e13647da44ba1310750cb98f1dec8dd | |
parent | bc8c837b6f6c14501b9f7ef607df99622120b48a (diff) |
This is a sufficient startup script to get a disk-full nfs server working.
On a flash based server or any (user) configuration where /var is in tmpfs
or ramfs (so is not populated on boot) the script will not work because
it must create the /var/lib/nfs directory and contents. Consequently at
present the script is not in the build.
-rw-r--r-- | packages/nfs-utils/files/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/nfs-utils/files/nfsserver | 106 |
2 files changed, 106 insertions, 0 deletions
diff --git a/packages/nfs-utils/files/.mtn2git_empty b/packages/nfs-utils/files/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/nfs-utils/files/.mtn2git_empty diff --git a/packages/nfs-utils/files/nfsserver b/packages/nfs-utils/files/nfsserver new file mode 100644 index 0000000000..3536f0db12 --- /dev/null +++ b/packages/nfs-utils/files/nfsserver @@ -0,0 +1,106 @@ +#!/bin/sh +# +# Startup script for nfs-utils +# +# The nfsd kernel module must exist along with its dependencies +modprobe -n nfsd || exit 0 +# +# The environment variable NFS_SERVERS may be set in /etc/default/nfsd +# Other control variables may be overridden here too +test -r /etc/default/nfsd && . /etc/default/nfsd +# +# Location of exectuables: +test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/mountd +test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/nfsd +# +# The user mode program must also exist (it just starts the kernel +# threads using the kernel module code). +test -x "$NFS_MOUNTD" || exit 0 +test -x "$NFS_NFSD" || exit 0 +# +# Default is 8 threads, value is settable between 1 and the truely +# ridiculous 99 +test "$NFS_SERVERS" -gt 0 && "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8 +# +#---------------------------------------------------------------------- +# Startup and shutdown functions. +# Actual startup/shutdown is at the end of this file. +#mountd +start_mountd(){ + echo -n 'starting mountd: ' + start-stop-daemon --start --exec "$NFS_MOUNTD" -- "$@" + echo done +} +stop_mountd(){ + echo -n 'stopping mountd: ' + start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD" + echo done +} +# +#nfsd +start_nfsd(){ + echo -n 'starting $1 nfsd kernel threads: ' + start-stop-daemon --start --exec "$NFS_NFSD" -- "$@" + echo done +} +delay_nfsd(){ + for delay in 0 1 2 3 4 5 6 7 8 9 + do + if pidof nfsd >/dev/null + then + echo -n . + sleep 1 + else + return 0 + fi + done + return 1 +} +stop_nfsd(){ + # WARNING: this kills any process with the executable + # name 'nfsd'. + echo -n 'stopping nfsd: ' + start-stop-daemon --stop --quiet --signal 1 --name nfsd + if delay_nfsd || { + echo failed + echo ' using signal 9: ' + start-stop-daemon --stop --quiet --signal 9 --name nfsd + delay_nfsd + } + then + echo done + # This will remove, recursively, dependencies + echo -n 'removing nfsd kernel module: ' + if modprobe -r nfsd + then + echo done + else + echo failed + fi + else + echo failed + fi +} +#---------------------------------------------------------------------- +# +# supported options: +# start +# stop +# reload: reloads the exports file +# restart: stops and starts mountd +#FIXME: need to create the /var/lib/nfs/... directories +case "$1" in +start) start_nfsd "$NFS_SERVERS" + start_mountd + test -r /etc/exports && exportfs -a;; +stop) exportfs -ua + stop_mountd + stop_nfsd;; +reload) test -r /etc/exports && exportfs -r;; +restart)exportfs -ua + stop_mountd + # restart does not restart the kernel threads, + # only the user mode processes + start_mountd + test -r /etc/exports && exportfs -a;; +esac |