summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorDaniel McGregor <daniel.mcgregor@vecima.com>2025-02-12 13:12:32 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-02-18 11:56:04 +0000
commit7d5f754f5e037bc2e748f0e3829656435923a143 (patch)
tree1049b1726af52c7ba5ae43897b0e0ab083477f89 /meta
parenta7ec517298c3bd51241b29d40bcb2b0a96920aa6 (diff)
downloadpoky-7d5f754f5e037bc2e748f0e3829656435923a143.tar.gz
nfs-utils: Start nfsv4 utilities with sysvinit
Rewrite the nfs sysvinit scripts to start the services required by nfsv4: gssd, idmapd, and statd. (From OE-Core rev: 2cca2dfb6acc25f1a6a25dc60423708a78cef85d) Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon294
-rw-r--r--meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver43
2 files changed, 289 insertions, 48 deletions
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon
index 4f07324a21..6c7b92bdb1 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon
@@ -1,63 +1,279 @@
1#!/bin/sh 1#!/bin/sh
2
2### BEGIN INIT INFO 3### BEGIN INIT INFO
3# Provides: nfs-common 4# Provides: nfs-common
4# Required-Start: $portmap $time 5# Required-Start: $portmap $time
5# Required-Stop: $portmap $time 6# Required-Stop: $portmap $time
6# Default-Start: S 7# Default-Start: S
7# Default-Stop: 0 1 6 8# Default-Stop: 0 1 6
8# Short-Description: NFS support for both client and server 9# Short-Description: NFS support files common to client and server
9# Description: NFS is a popular protocol for file sharing across 10# Description: NFS is a popular protocol for file sharing across
10# TCP/IP networks. This service provides various 11# TCP/IP networks. This service provides various
11# support functions for NFS mounts. 12# support functions for NFS mounts.
12### END INIT INFO 13### END INIT INFO
13#
14# Startup script for nfs-utils
15#
16#
17# Location of executables:
18 14
19# Source function library. 15# What is this?
16DESC="NFS common utilities"
17
18# Read config
19DEFAULTFILE=/etc/default/nfs-utils
20NEED_STATD=
21NEED_GSSD=
22if nfsconf --isset general pipefs-directory; then
23 PIPEFS_MOUNTPOINT=$(nfsconf --get general pipefs-directory)
24else
25 PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
26fi
27if [ -f $DEFAULTFILE ]; then
28 . $DEFAULTFILE
29fi
30
20. /etc/init.d/functions 31. /etc/init.d/functions
21 32
22test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd 33# Exit if required binaries are missing.
23test -z "$STATD_PID" && STATD_PID=/run/rpc.statd.pid 34[ -x /usr/sbin/rpc.statd ] || exit 0
35
24# 36#
25# The default state directory is /var/lib/nfs 37# Parse the fstab file, and determine whether we need gssd. (The
26test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs 38# /etc/defaults settings, if any, will override our autodetection.) This code
39# is partially adapted from the mountnfs.sh script in the sysvinit package.
27# 40#
28#---------------------------------------------------------------------- 41AUTO_NEED_GSSD=no
29# Startup and shutdown functions. 42
30# Actual startup/shutdown is at the end of this file. 43if [ -f /etc/fstab ]; then
31 44 exec 9<&0 </etc/fstab
32start_statd(){ 45
33 echo -n "starting statd: " 46 while read -r DEV _ _ OPTS _
34 start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID" 47 do
35 echo done 48 case $DEV in
49 ''|\#*)
50 continue
51 ;;
52 esac
53 OLDIFS="$IFS"
54 IFS=","
55 for OPT in $OPTS; do
56 case "$OPT" in
57 sec=krb5|sec=krb5i|sec=krb5p)
58 AUTO_NEED_GSSD=yes
59 ;;
60 esac
61 done
62 IFS="$OLDIFS"
63 done
64
65 exec 0<&9 9<&-
66fi
67
68case "$NEED_STATD" in
69 yes|no)
70 ;;
71 *)
72 NEED_STATD=yes
73 ;;
74esac
75
76case "$NEED_IDMAPD" in
77 yes|no)
78 ;;
79 *)
80 NEED_IDMAPD=yes
81 ;;
82esac
83
84case "$NEED_GSSD" in
85 yes|no)
86 ;;
87 *)
88 NEED_GSSD=$AUTO_NEED_GSSD
89 ;;
90esac
91
92do_modprobe() {
93 if [ -x /sbin/modprobe ] && [ -f /proc/modules ]
94 then
95 modprobe -q "$1" || true
96 fi
97}
98
99do_mount() {
100 if ! grep -E -qs "$1\$" /proc/filesystems
101 then
102 return 1
103 fi
104 if ! mountpoint -q "$2"
105 then
106 mount -t "$1" "$1" "$2"
107 return
108 fi
109 return 0
36} 110}
37stop_statd(){ 111
38 echo -n 'stopping statd: ' 112do_umount() {
39 start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID" 113 if mountpoint -q "$1"
40 echo done 114 then
115 umount "$1"
116 fi
117 return 0
41} 118}
42#---------------------------------------------------------------------- 119
43# 120# See how we were called.
44# supported options:
45# start
46# stop
47# restart: stops and starts mountd
48#FIXME: need to create the /var/lib/nfs/... directories
49case "$1" in 121case "$1" in
50 start) 122 start)
51 start_statd;; 123 echo -n "Starting $DESC ..."
124
125 if [ "$NEED_STATD" = yes ]; then
126 echo -n " statd"
127
128 # See if rpcbind is running
129 if [ -x /usr/sbin/rpcinfo ]; then
130 /usr/sbin/rpcinfo -p >/dev/null 2>&1
131 RET=$?
132 if [ $RET != 0 ]; then
133 echo
134 echo "Not starting: portmapper is not running"
135 exit 0
136 fi
137 fi
138 start-stop-daemon --start --oknodo --quiet \
139 --pidfile /run/rpc.statd.pid \
140 --exec /sbin/rpc.statd
141 RET=$?
142 if [ $RET != 0 ]; then
143 echo " failed" $RET
144 exit $RET
145 else
146 if [ -d /run/sendsigs.omit.d ]; then
147 rm -f /run/sendsigs.omit.d/statd
148 ln -s /run/rpc.statd.pid /run/sendsigs.omit.d/statd
149 fi
150 fi
151 fi
152
153 # Don't start idmapd and gssd if we don't have them (say, if /usr is not
154 # up yet).
155 [ -x /usr/sbin/rpc.idmapd ] || NEED_IDMAPD=no
156 [ -x /usr/sbin/rpc.gssd ] || NEED_GSSD=no
157
158 if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
159 then
160 do_modprobe sunrpc
161 do_modprobe nfs
162 do_modprobe nfsd
163 mkdir -p "$PIPEFS_MOUNTPOINT"
164 if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
165 then
166 if [ "$NEED_IDMAPD" = yes ]
167 then
168 ecno -n " idmapd"
169 start-stop-daemon --start --oknodo --quiet \
170 --exec /usr/sbin/rpc.idmapd
171 RET=$?
172 if [ $RET != 0 ]; then
173 echo " failed" $RET
174 exit $RET
175 fi
176 fi
177 if [ "$NEED_GSSD" = yes ]
178 then
179 do_modprobe rpcsec_gss_krb5
180 echo -n " gssd"
181
182 start-stop-daemon --start --oknodo --quiet \
183 --exec /usr/sbin/rpc.gssd
184 RET=$?
185 if [ $RET != 0 ]; then
186 echo " failed" $RET
187 exit $RET
188 fi
189 fi
190 fi
191 fi
192 echo " done"
193 ;;
194
52 stop) 195 stop)
53 stop_statd;; 196 echo -n "Stopping $DESC ..."
197
198 if [ "$NEED_GSSD" = yes ]
199 then
200 echo -n " gssd"
201 start-stop-daemon --stop --oknodo --quiet \
202 --name rpc.gssd
203 RET=$?
204 if [ $RET != 0 ]; then
205 echo " failed" $RET
206 exit $RET
207 fi
208 fi
209 if [ "$NEED_IDMAPD" = yes ]
210 then
211 echo -n " idmapd"
212 start-stop-daemon --stop --oknodo --quiet \
213 --name rpc.idmapd
214 RET=$?
215 if [ $RET != 0 ]; then
216 echo " failed" $RET
217 exit $RET
218 fi
219 fi
220 if [ "$NEED_STATD" = yes ]
221 then
222 echo -n " statd"
223 start-stop-daemon --stop --oknodo --quiet \
224 --name rpc.statd
225 RET=$?
226 if [ $RET != 0 ]; then
227 echo " failed" $RET
228 exit $RET
229 fi
230 fi
231 do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
232 echo " done"
233 ;;
234
54 status) 235 status)
55 status $NFS_STATD 236 if [ "$NEED_STATD" = yes ]
56 exit $?;; 237 then
57 restart) 238 if ! pidof rpc.statd >/dev/null
239 then
240 echo "rpc.statd not running"
241 exit 3
242 fi
243 fi
244
245 if [ "$NEED_GSSD" = yes ]
246 then
247 if ! pidof rpc.gssd >/dev/null
248 then
249 echo "rpc.gssd not running"
250 exit 3
251 fi
252 fi
253
254 if [ "$NEED_IDMAPD" = yes ]
255 then
256 if ! pidof rpc.idmapd >/dev/null
257 then
258 echo "rpc.idmapd not running"
259 exit 3
260 fi
261 fi
262
263 echo "all daemons running"
264 exit 0
265 ;;
266
267 restart | force-reload)
58 $0 stop 268 $0 stop
59 $0 start;; 269 sleep 1
270 $0 start
271 ;;
272
60 *) 273 *)
61 echo "Usage: $0 {start|stop|status|restart}" 274 echo "Usage: nfscommon {start|stop|status|restart}"
62 exit 1;; 275 exit 1
276 ;;
63esac 277esac
278
279exit 0
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
index 0f5747cc6d..cb6c1b4d08 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
@@ -1,8 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2
2### BEGIN INIT INFO 3### BEGIN INIT INFO
3# Provides: nfs-kernel-server 4# Provides: nfs-kernel-server
4# Required-Start: $remote_fs nfs-common $portmap hwclock 5# Required-Start: $remote_fs nfs-common $portmap $time
5# Required-Stop: $remote_fs nfs-common $portmap hwclock 6# Required-Stop: $remote_fs nfs-common $portmap $time
7# Should-Start: $named
6# Default-Start: 2 3 4 5 8# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6 9# Default-Stop: 0 1 6
8# Short-Description: Kernel NFS server support 10# Short-Description: Kernel NFS server support
@@ -19,20 +21,25 @@
19# 21#
20# The environment variable NFS_SERVERS may be set in /etc/default/nfsd 22# The environment variable NFS_SERVERS may be set in /etc/default/nfsd
21# Other control variables may be overridden here too 23# Other control variables may be overridden here too
22test -r /etc/default/nfsd && . /etc/default/nfsd 24test -r /etc/default/nfs-utils && . /etc/default/nfs-utils
23# 25#
24# Location of executables: 26# Location of executables:
25test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd 27test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
26test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd 28test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
29test -x "$NFS_SVCGSSD" || NFS_SVCGSSD=/usr/sbin/rpc.svcgssd
27# 30#
28# The user mode program must also exist (it just starts the kernel 31# The user mode program must also exist (it just starts the kernel
29# threads using the kernel module code). 32# threads using the kernel module code).
30test -x "$NFS_MOUNTD" || exit 0 33test -x "$NFS_MOUNTD" || exit 0
31test -x "$NFS_NFSD" || exit 0 34test -x "$NFS_NFSD" || exit 0
32# 35
33# Default is 8 threads, value is settable between 1 and the truely 36case "$NEED_SVCGSSD" in
34# ridiculous 99 37 yes|no)
35test "$NFS_SERVERS" != "" && test "$NFS_SERVERS" -gt 0 && test "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8 38 ;;
39 *)
40 NEED_SVCGSSD=no
41 ;;
42esac
36# 43#
37#---------------------------------------------------------------------- 44#----------------------------------------------------------------------
38# Startup and shutdown functions. 45# Startup and shutdown functions.
@@ -49,6 +56,22 @@ stop_mountd(){
49 echo done 56 echo done
50} 57}
51# 58#
59#svcgssd
60start_svcgssd(){
61 modprobe -q rpcsec_gss_krb5
62 if [ "$NEED_SVCGSSD" = "yes" ]; then
63 echo -n "starting svcgssd: "
64 start-stop-daemon --start --exec "$NFS_SVCGSSD" -- "$@"
65 echo done
66 fi
67}
68stop_svcgssd(){
69 if [ "$NEED_SVCGSSD" = "yes" ]; then
70 echo -n "stop svcgssd: "
71 start-stop-daemon --stop --exec "$NFS_SVCGSSD"
72 echo done
73 fi
74}
52#nfsd 75#nfsd
53start_nfsd(){ 76start_nfsd(){
54 modprobe -q nfsd 77 modprobe -q nfsd
@@ -62,7 +85,7 @@ start_nfsd(){
62 exit 1 85 exit 1
63 } 86 }
64 87
65 echo -n "starting $1 nfsd kernel threads: " 88 echo -n "starting nfsd: "
66 start-stop-daemon --start --exec "$NFS_NFSD" -- "$@" 89 start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
67 echo done 90 echo done
68} 91}
@@ -108,11 +131,13 @@ stop_nfsd(){
108case "$1" in 131case "$1" in
109 start) 132 start)
110 test -r /etc/exports && exportfs -r 133 test -r /etc/exports && exportfs -r
111 start_nfsd "$NFS_SERVERS" 134 start_nfsd
135 start_svcgssd
112 start_mountd 136 start_mountd
113 test -r /etc/exports && exportfs -a;; 137 test -r /etc/exports && exportfs -a;;
114 stop) exportfs -ua 138 stop) exportfs -ua
115 stop_mountd 139 stop_mountd
140 stop_svcgssd
116 stop_nfsd;; 141 stop_nfsd;;
117 status) 142 status)
118 status /usr/sbin/rpc.mountd 143 status /usr/sbin/rpc.mountd