Ticket #15454: nfs-server2

File nfs-server2, 3.3 KB (added by Bruce Dubbs, 3 years ago)

Test rewrite of nfs-server boot script.

Line 
1#!/bin/sh
2########################################################################
3# Begin nfs-server
4#
5# Description : Start nfs server
6#
7# Authors : Ken Moffat - ken@linuxfromscratch.org
8# Bruce Dubbs - bdubbs@linuxfromscratch.org
9# Douglas R. Reno - renodr@linuxfromscratch.org
10#
11# Version : BLFS 8.1
12#
13########################################################################
14
15### BEGIN INIT INFO
16# Provides: nfs-server
17# Required-Start: $network $portmap
18# Should-Start: networkmanager wicd
19# Required-Stop: $network $portmap
20# Should-Stop: networkmanager wicd
21# Default-Start: 3 4 5
22# Default-Stop: 0 1 2 6
23# Short-Description: Starts the nfs server
24# Description: Starts the nfs server and exports directories.
25# X-LFS-Provided-By: BLFS
26### END INIT INFO
27
28. /usr/lib/lsb/init-functions
29
30 #$LastChangedBy: dj $
31 #$Date: 2020-08-17 01:20:21 -0500 (Mon, 17 Aug 2020) $
32
33 . /etc/sysconfig/nfs-server
34
35nfs_status()
36{
37 local nfsiod
38 local nfsd
39 local pid
40
41 nfsiod=$(ps -ef|grep '\[nfsiod]$'|sed 's/ \+/\t/g'| cut -f2)
42 if [ -z "${nfsiod}" ]; then
43 /usr/bin/echo -e "${INFO}[nfsiod] is not running.${NORMAL}"
44 else
45 /usr/bin/echo -e "${INFO}[nfsiod] is running with Process" \
46 "ID ${nfsiod}.${NORMAL}"
47 fi
48
49 nfsd=""
50 for pid in $(ps -ef|grep '\[nfsd]$'|sed 's/ \+/\t/g'| cut -f2); do
51 nfsd="${nfsd} ${pid}"
52 done
53
54 if [ -z "${nfsd}" ]; then
55 /usr/bin/echo -e "${INFO}No [nfsd] processes are running.${NORMAL}"
56 else
57 /usr/bin/echo -e "${INFO}[nfsd] is running with Process" \
58 "ID(s)${nfsd}.${NORMAL}"
59 fi
60}
61
62
63 case "$1" in
64 start)
65 log_info_msg "Starting NFS statd..."
66 start_daemon /usr/sbin/rpc.statd --no-notify
67 evaluate_retval
68
69 log_info_msg "Starting NFS nfsd..."
70 start_daemon /usr/sbin/rpc.nfsd -p $PORT $PROCESSES
71 evaluate_retval
72
73 log_info_msg "Starting NFS mountd..."
74 start_daemon /usr/sbin/rpc.mountd
75 evaluate_retval
76
77 # Make certain that the list is refreshed on a restart.
78 log_info_msg "Exporting NFS Filesystems..."
79 /usr/sbin/exportfs -r 2>&1 > /dev/null
80 evaluate_retval
81 ;;
82
83 stop)
84 log_info_msg "Removing NFS Exported Filesystems..."
85 /usr/sbin/exportfs -au 2>&1 > /dev/null
86 evaluate_retval
87
88 log_info_msg "Stopping NFS statd..."
89 killproc /usr/sbin/rpc.statd
90 evaluate_retval
91
92 log_info_msg "Stopping NFS nfsd..."
93 /usr/sbin/rpc.nfsd 0
94 evaluate_retval
95
96 log_info_msg "Stopping NFS mountd..."
97 killproc /usr/sbin/rpc.mountd
98 evaluate_retval
99
100 # Remove a pid file that isn't done automatically
101 if [ -f /run/rpc.statd.pid ]; then
102 log_success_msg "Removing the rpc.statd pid file if it exists"
103 rm -f /run/rpc.statd.pid
104 fi
105 ;;
106
107 reload)
108 log_info_msg "Reloading NFS Server..."
109 /usr/sbin/exportfs -r
110 evaluate_retval
111 ;;
112
113 restart)
114 $0 stop
115 sleep 1
116 $0 start
117 ;;
118
119 status)
120 statusproc /sbin/rpc.mountd
121 statusproc /sbin/rpc.statd
122 ## Special case for nfsd with no full path
123 nfs_status
124 ;;
125
126 *)
127 echo "Usage: $0 {start|stop|reload|restart|status}"
128 exit 1
129 ;;
130esac
131
132# End /etc/init.d/nfs-server