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