6 DAEMON_DEPENDS
=('rpcbind')
17 # rpc.statd daemon & binary location
18 STATD_DAEMON_NAME
=rpc.statd
19 STATD
="/usr/sbin/rpc.statd"
21 # rpc.idmapd daemon & binary location
22 IDMAPD_DAEMON_NAME
=rpc.idmapd
23 IDMAPD
="/usr/sbin/rpc.idmapd"
25 # rpc.gssd daemon & binary location
26 GSSD_DAEMON_NAME
=rpc.gssd
27 GSSD
="/usr/sbin/rpc.gssd"
31 .
/etc
/conf.d
/$daemon_name.conf
33 # Default mountpoint and options for rpc_pipefs filesystem
34 [ -z "$PIPEFS_MOUNTPOINT" ] && PIPEFS_MOUNTPOINT
="/var/lib/nfs/rpc_pipefs"
35 [ -z "$PIPEFS_MOUNTOPTS" ] && PIPEFS_MOUNTOPTS
="defaults"
37 # Parse the fstab file, and determine whether we need idmapd and gssd. (The
38 # /etc/conf.d/nfs-common settings, if any, will override our autodetection.)
42 if [ -f /etc
/fstab
]; then
45 while read DEV MTPT FSTYPE OPTS REST
; do
46 if [ "$FSTYPE" = "nfs4" ]; then
50 sec
=krb5|
*,sec
=krb5|sec
=krb5
,*|
*,sec
=krb5i
,*|sec
=krb5i|
*,sec
=krb5i|sec
=krb5i
,*|
*,sec
=krb5i
,*|sec
=krb5p|
*,sec
=krb5p|sec
=krb5p
,*|
*,sec
=krb5p
,*)
59 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
60 # to autodetect whether there are NFSv4 exports or not, and idmapd is not a
61 # particularily heavy daemon, so we auto-enable it if we find an /etc/exports
62 # file. This does not mean that there are NFSv4 or other mounts active (or
63 # even that nfs-kernel-server is installed), but it matches what the "start"
64 # condition in nfs-kernel-server's init script does, which has a value in
66 if [ -f /etc
/exports
] && grep -q '^[[:space:]]*[^#]*/' /etc
/exports
; then
78 case "$NEED_IDMAPD" in
82 NEED_IDMAPD
=$AUTO_NEED_IDMAPD
90 NEED_GSSD
=$AUTO_NEED_GSSD
95 if [ -x /sbin
/modprobe
-a -f /proc
/modules
]; then
96 modprobe
-q "$1" || true
101 if ! grep -E "$1\$" /proc
/filesystems
&> /dev
/null
; then
105 if grep -vw "$1" /proc
/mounts
&> /dev
/null
; then
106 if ! mountpoint
-q "$2" ; then
107 mount
-t "$1" "$1" "$2" -o "$3"
115 if mountpoint
-q "$1" ; then
127 ck_depends
${DAEMON_DEPENDS[@]}
130 if [ "$NEED_STATD" = yes ]; then
131 stat_busy
"Starting $STATD_DAEMON_NAME daemon"
132 PID
=$
(get_pid
$STATD)
133 if [ -z "$PID" ]; then
134 [ -f /var
/run
/$STATD_DAEMON_NAME.pid
] && rm -f /var
/run
/$STATD_DAEMON_NAME.pid
139 if [ $rc -gt 0 ]; then
143 echo $
(get_pid
$STATD) > /var
/run
/$STATD_DAEMON_NAME.pid
151 /usr
/sbin
/sm-notify
$SMNOTIFY_OPTS
154 if [ "$NEED_IDMAPD" = yes ] ||
[ "$NEED_GSSD" = yes ]; then
155 stat_busy
"Mounting pipefs filesystem"
159 do_mount rpc_pipefs
"$PIPEFS_MOUNTPOINT" "$PIPEFS_MOUNTOPTS"
161 if [ $rc -gt 0 ]; then
166 if [ "$NEED_IDMAPD" = yes ]; then
167 stat_busy
"Starting $IDMAPD_DAEMON_NAME daemon"
168 PID
=$
(get_pid
$IDMAPD)
169 if [ -z "$PID" ]; then
170 [ -f /var
/run
/$IDMAPD_DAEMON_NAME.pid
] && rm -f /var
/run
/$IDMAPD_DAEMON_NAME.pid
175 if [ $rc -gt 0 ]; then
179 echo $
(get_pid
$IDMAPD) > /var
/run
/$IDMAPD_DAEMON_NAME.pid
188 if [ "$NEED_GSSD" = yes ]; then
189 do_modprobe rpcsec_gss_krb5
190 stat_busy
"Starting $GSSD_DAEMON_NAME daemon"
192 if [ -z "$PID" ]; then
193 [ -f /var
/run
/$GSSD_DAEMON_NAME.pid
] && rm -f /var
/run
/$GSSD_DAEMON_NAME.pid
198 if [ $rc -gt 0 ]; then
202 echo $
(get_pid
$GSSD) > /var
/run
/$GSSD_DAEMON_NAME.pid
212 add_daemon
$daemon_name
217 if [ "$NEED_IDMAPD" = yes ] ||
[ "$NEED_GSSD" = yes ]; then
219 if [ "$NEED_GSSD" = yes ]; then
220 stat_busy
"Stopping $GSSD_DAEMON_NAME daemon"
223 [ ! -z "$PID" ] && kill $PID &> /dev
/null
226 if [ $rc -gt 0 ]; then
230 rm -f /var
/run
/$GSSD_DAEMON_NAME.pid
&> /dev
/null
235 if [ "$NEED_IDMAPD" = yes ]; then
236 stat_busy
"Stopping $IDMAPD_DAEMON_NAME daemon"
237 PID
=$
(get_pid
$IDMAPD)
239 [ ! -z "$PID" ] && kill $PID &> /dev
/null
242 if [ $rc -gt 0 ]; then
246 rm -f /var
/run
/$IDMAPD_DAEMON_NAME.pid
&> /dev
/null
250 do_umount
"$PIPEFS_MOUNTPOINT" 2>/dev
/null || true
253 if [ "$NEED_STATD" = yes ]; then
254 stat_busy
"Stopping $STATD_DAEMON_NAME daemon"
255 PID
=$
(get_pid
$STATD)
257 [ ! -z "$PID" ] && kill $PID &> /dev
/null
260 if [ $rc -gt 0 ]; then
264 rm -f /var
/run
/$STATD_DAEMON_NAME.pid
&> /dev
/null
269 rm_daemon
$daemon_name
273 stat_busy
"Checking $daemon_name status";
274 ck_status
$daemon_name
276 if [ "$NEED_STATD" = yes ]; then
277 stat_busy
"Daemon $STATD_DAEMON_NAME running"
278 PID
=$
(get_pid
$STATD)
279 if [ -z "$PID" ]; then
286 if [ "$NEED_GSSD" = yes ]; then
287 stat_busy
"Daemon $GSSD_DAEMON_NAME running"
289 if [ -z "$PID" ]; then
296 if [ "$NEED_IDMAPD" = yes ]; then
297 stat_busy
"Daemon $IDMAPD_DAEMON_NAME running"
298 PID
=$
(get_pid
$IDMAPD)
299 if [ -z "$PID" ]; then
314 echo "usage: $0 {start|stop|status|restart}"