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
|
2007-09-25 07:59:56 +05:30
|
|
|
local pmap=""
|
2007-10-09 21:03:05 +05:30
|
|
|
if need_portmap; then
|
2008-01-01 23:41:45 +05:30
|
|
|
pmap="${pmap} rpc.statd"
|
2007-09-25 07:59:56 +05:30
|
|
|
[ -x /etc/init.d/rpcbind ] \
|
|
|
|
&& pmap="rpcbind" \
|
|
|
|
|| 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-01-01 23:41:45 +05:30
|
|
|
use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd
|
2008-03-03 02:43:21 +05:30
|
|
|
keyword nojail noprefix
|
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=
|
|
|
|
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
|
|
|
|
|
|
|
|
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-01-11 17:43:46 +05:30
|
|
|
# If the nfsmount script took care of the nfs
|
|
|
|
# filesystems, then there's no point in trying
|
|
|
|
# them twice
|
|
|
|
service_started nfsmount && continue
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
# Only try to mount NFS filesystems if portmap was
|
|
|
|
# started. This is to fix "hang" problems for new
|
|
|
|
# users who do not add portmap to the default runlevel.
|
|
|
|
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
|
|
|
}
|