2008-03-02 21:14:01 +00:00
|
|
|
#!@PREFIX@/sbin/runscript
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-29 19:46:31 -04:00
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2007-07-10 19:09:41 +00:00
|
|
|
description="Mounts network shares according to /etc/fstab."
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
need_portmap()
|
|
|
|
{
|
2007-12-14 14:12:38 +00:00
|
|
|
local opts=
|
|
|
|
local IFS="
|
2007-09-25 02:29:56 +00:00
|
|
|
"
|
2007-12-14 14:12:38 +00:00
|
|
|
set -- $(fstabinfo --options --fstype nfs,nfs4)
|
|
|
|
for opts; do
|
2009-04-27 07:51:18 +00:00
|
|
|
case ,$opts, in
|
2007-11-28 15:45:03 +00:00
|
|
|
*,noauto,*|*,nolock,*);;
|
2007-09-25 02:29:56 +00:00
|
|
|
*) return 0;;
|
|
|
|
esac
|
2007-04-05 11:18:42 +00:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
depend()
|
|
|
|
{
|
|
|
|
# Only have portmap as a dependency if there is a nfs mount in fstab
|
|
|
|
# that is set to mount at boot
|
2008-04-08 23:25:48 +00:00
|
|
|
local pmap=
|
2007-10-09 15:33:05 +00:00
|
|
|
if need_portmap; then
|
2008-04-08 23:25:48 +00:00
|
|
|
pmap="rpc.statd"
|
2008-03-05 12:27:11 +00:00
|
|
|
[ -x @SYSCONFDIR@/init.d/rpcbind ] \
|
2009-04-27 07:51:18 +00:00
|
|
|
&& pmap="$pmap rpcbind" \
|
|
|
|
|| pmap="$pmap portmap"
|
2007-04-05 11:18:42 +00:00
|
|
|
fi
|
|
|
|
|
2007-08-15 14:49:41 +00:00
|
|
|
config /etc/fstab
|
2009-04-27 07:51:18 +00:00
|
|
|
need net $pmap
|
2008-05-10 11:09:52 +00:00
|
|
|
use afc-client amd autofs openvpn
|
2008-08-27 16:06:01 +00:00
|
|
|
use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd
|
2009-07-01 00:07:32 +01:00
|
|
|
keyword -jail -prefix -vserver
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
start()
|
2011-01-17 04:49:07 -05:00
|
|
|
{
|
2007-04-05 11:18:42 +00:00
|
|
|
local myneed= myuse= pmap="portmap" nfsmounts=
|
2008-03-05 12:27:11 +00:00
|
|
|
[ -x @SYSCONFDIR@/init.d/rpcbind ] && pmap="rpcbind"
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2010-12-07 11:54:03 -06:00
|
|
|
local x= fs= rc=
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $net_fs_list; do
|
|
|
|
case "$x" in
|
2007-04-05 11:18:42 +00:00
|
|
|
nfs|nfs4)
|
2008-03-23 12:24:15 +00:00
|
|
|
# If the nfsmount script took care of the nfs
|
2008-01-11 12:13:46 +00:00
|
|
|
# filesystems, then there's no point in trying
|
|
|
|
# them twice
|
|
|
|
service_started nfsmount && continue
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2008-03-23 12:24:15 +00:00
|
|
|
# Only try to mount NFS filesystems if portmap was
|
2008-01-11 12:13:46 +00:00
|
|
|
# started. This is to fix "hang" problems for new
|
2008-03-23 12:24:15 +00:00
|
|
|
# users who do not add portmap to the default runlevel.
|
2009-04-27 07:51:18 +00:00
|
|
|
if need_portmap && ! service_started "$pmap"; then
|
2008-01-11 12:13:46 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
;;
|
2007-04-05 11:18:42 +00:00
|
|
|
esac
|
2009-04-27 07:51:18 +00:00
|
|
|
fs="$fs${fs:+,}$x"
|
2007-04-05 11:18:42 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
ebegin "Mounting network filesystems"
|
2009-04-27 07:51:18 +00:00
|
|
|
mount -at $fs
|
2010-12-07 11:54:03 -06:00
|
|
|
rc=$?
|
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
mount -a -O _netdev
|
|
|
|
rc=$?
|
|
|
|
fi
|
|
|
|
ewend $rc "Could not mount all network filesystems"
|
2007-04-05 11:18:42 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
stop()
|
|
|
|
{
|
2007-04-05 11:18:42 +00:00
|
|
|
local x= fs=
|
|
|
|
|
|
|
|
ebegin "Unmounting network filesystems"
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $net_fs_list; do
|
|
|
|
fs="$fs${fs:+,}$x"
|
2007-10-09 15:33:05 +00:00
|
|
|
done
|
2009-04-27 07:51:18 +00:00
|
|
|
if [ -n "$fs" ]; then
|
|
|
|
umount -at $fs || eerror "Failed to simply unmount filesystems"
|
2007-04-05 11:18:42 +00:00
|
|
|
fi
|
|
|
|
|
2007-10-09 15:33:05 +00:00
|
|
|
eindent
|
|
|
|
fs=
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $net_fs_list; do
|
|
|
|
fs="$fs${fs:+|}$x"
|
2007-10-09 15:33:05 +00:00
|
|
|
done
|
2009-04-27 07:51:18 +00:00
|
|
|
[ -n "$fs" ] && fs="^($fs)$"
|
|
|
|
do_unmount umount ${fs:+--fstype-regex} $fs --netdev
|
2007-10-09 15:33:05 +00:00
|
|
|
retval=$?
|
|
|
|
|
|
|
|
eoutdent
|
2010-12-07 11:54:03 -06:00
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
umount -a -O _netdev
|
|
|
|
retval=$?
|
|
|
|
fi
|
2009-04-27 07:51:18 +00:00
|
|
|
eend $retval "Failed to unmount network filesystems"
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|