2008-03-03 02:44:01 +05:30
|
|
|
#!@PREFIX@/sbin/runscript
|
2008-01-11 21:01:10 +05:30
|
|
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
|
|
|
# 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
|
|
|
|
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 ] \
|
2008-04-09 04:55:48 +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
|
2007-09-25 07:59:56 +05:30
|
|
|
need net ${pmap}
|
2008-05-10 16:39:52 +05:30
|
|
|
use afc-client amd autofs openvpn
|
|
|
|
use dns nfs nfsmount portmap rpcbind rpc.statd
|
2008-08-19 12:14:47 +05:30
|
|
|
keyword nojail noprefix novserver
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
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
|
|
|
|
|
|
|
local x= fs=
|
2007-11-23 17:34:11 +05:30
|
|
|
for x in ${net_fs_list}; do
|
2007-04-05 16:48:42 +05:30
|
|
|
case "${x}" in
|
|
|
|
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.
|
2008-01-11 17:43:46 +05:30
|
|
|
if need_portmap && ! service_started "${pmap}"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
|
|
|
fs="${fs}${fs:+,}${x}"
|
|
|
|
done
|
|
|
|
|
|
|
|
ebegin "Mounting network filesystems"
|
|
|
|
mount -at ${fs}
|
2007-12-14 19:42:38 +05:30
|
|
|
ewend $? "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"
|
2007-10-09 21:03:05 +05:30
|
|
|
. "${RC_LIBDIR}/sh/rc-mount.sh"
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for x in ${net_fs_list}; do
|
2007-10-09 21:03:05 +05:30
|
|
|
fs="${fs}${fs:+,}${x}"
|
|
|
|
done
|
|
|
|
if [ -n "${fs}" ]; then
|
2008-01-11 17:43:46 +05:30
|
|
|
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=
|
2007-11-23 17:34:11 +05:30
|
|
|
for x in ${net_fs_list}; do
|
2007-10-09 21:03:05 +05:30
|
|
|
fs="${fs}${fs:+|}${x}"
|
|
|
|
done
|
|
|
|
[ -n "${fs}" ] && fs="^(${fs})$"
|
|
|
|
do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev
|
|
|
|
retval=$?
|
|
|
|
|
|
|
|
eoutdent
|
|
|
|
eend ${retval} "Failed to unmount network filesystems"
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|