wok view nfs-utils/stuff/etc/init.d/nfsd @ rev 25533

nfs-utils: made stop and restart working in /etc/init.d/nfsd
author Hans-G?nter Theisgen
date Tue Feb 28 14:41:52 2023 +0100 (15 months ago)
parents ff5fd8788cd9
children 23441bc814ae
line source
1 #!/bin/sh
2 # /etc/init.d/nfsd: Start, stop and restart NFS daemon on SliTaz, at boot
3 # time or with the command line.
4 #
5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf.
7 #
9 . /etc/init.d/rc.functions
11 NAME=NFSd
12 DESC="$(_ '%s daemon' NFS)"
13 DAEMON=/usr/sbin/rpc.nfsd
14 PID_FILE=/var/run/nfsd.pid
15 OPTIONS="8" # start 8 threads, default is 1 if omitted
16 . /etc/daemons.conf
17 [ -z "$NFSD_OPTIONS" ] || OPTIONS="$NFSD_OPTIONS"
19 case "$1" in
20 (start)
21 if active_pidfile $PID_FILE nfsd
22 then
23 _ '%s is already running.' $NAME
24 exit 1
25 fi
26 action 'Starting %s: %s...' "$DESC" $NAME
27 # Start rpcbind when not already running:
28 [ -n "$(pidof rpcbind)" ] || rpcbind
29 # Export directories specified in /etc/exports:
30 /usr/sbin/exportfs -r
31 # Start nfsd:
32 $DAEMON $OPTIONS
33 p=$(pidof nfsd)
34 echo "${p%% *}" > $PID_FILE
35 # Start RPC mount daemon:
36 /usr/sbin/rpc.mountd
37 status
38 ;;
39 (stop)
40 if ! active_pidfile $PID_FILE nfsd
41 then
42 _ '%s is not running.' $NAME
43 exit 1
44 fi
45 action 'Stopping %s: %s...' "$DESC" $NAME
46 # Stop RPC mount daemon:
47 killall -q -KILL rpc.mountd
48 # Stop all threads of nfsd:
49 p=$(pidof nfsd)
50 # remove first pid, supposing it is own pid:
51 p=${p#* }
52 kill -KILL $p
53 # Unexport all exported directories:
54 /usr/sbin/exportfs -au
55 # flush kernel's export table:
56 /usr/sbin/exportfs -f
57 status
58 ;;
59 (restart)
60 if ! active_pidfile $PID_FILE nfsd
61 then
62 _ '%s is not running.' $NAME
63 exit 1
64 fi
65 action 'Restarting %s: %s...' "$DESC" $NAME
66 # Stop RPC mount daemon:
67 killall -q -KILL rpc.mountd
68 # Stop all instances of nfsd:
69 p=$(pidof nfsd)
70 # remove first pid, supposing it is own pid:
71 p=${p#* }
72 kill -KILL $p
73 # Unexport all exported directories:
74 /usr/sbin/exportfs -au
75 # flush kernel's export table:
76 /usr/sbin/exportfs -f
77 # Wait before starting:
78 sleep 2
79 # Export directories specified in /etc/exports:
80 /usr/sbin/exportfs -r
81 # Start nfsd:
82 $DAEMON $OPTIONS
83 p=$(pidof nfsd)
84 echo "${p%% *}" > $PID_FILE
85 # Start RPC mount daemon:
86 /usr/sbin/rpc.mountd
87 status
88 ;;
89 (*)
90 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
91 newline
92 exit 1
93 ;;
94 esac
96 exit 0