| 1 |
#!/sbin/runscript
|
| 2 |
# Copyright 1999-2007 Gentoo Foundation
|
| 3 |
# Distributed under the terms of the GNU General Public License v2
|
| 4 |
|
| 5 |
description="Mounts network shares according to /etc/fstab."
|
| 6 |
|
| 7 |
have_nfs() {
|
| 8 |
local IFS=\n x=
|
| 9 |
set -- $(fstabinfo --fstype nfs,nfs4)
|
| 10 |
for x in "$@" ; do
|
| 11 |
! fstabinfo --opts "${x}" | grep -q noauto && return 0
|
| 12 |
done
|
| 13 |
return 1
|
| 14 |
}
|
| 15 |
|
| 16 |
depend() {
|
| 17 |
local myneed= myuse= pmap="portmap" nfsmounts= x
|
| 18 |
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
|
| 19 |
|
| 20 |
# Only have Portmap as a dependency if there is a nfs mount in fstab that
|
| 21 |
# is set to mount at boot
|
| 22 |
if have_nfs ; then
|
| 23 |
myneed="${myneed} ${pmap}"
|
| 24 |
else
|
| 25 |
myuse="${myuse} ${pmap}"
|
| 26 |
fi
|
| 27 |
|
| 28 |
need net ${myneed}
|
| 29 |
use afc-client amd autofs dns nfs nfsmount ${myuse}
|
| 30 |
}
|
| 31 |
|
| 32 |
start() {
|
| 33 |
local myneed= myuse= pmap="portmap" nfsmounts=
|
| 34 |
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
|
| 35 |
|
| 36 |
local x= fs=
|
| 37 |
for x in ${RC_NET_FS_LIST} ; do
|
| 38 |
case "${x}" in
|
| 39 |
nfs|nfs4)
|
| 40 |
# If the nfsmount script took care of the nfs filesystems,
|
| 41 |
# then there's no point in trying them twice
|
| 42 |
service_started nfsmount && continue
|
| 43 |
|
| 44 |
# Only try to mount NFS filesystems if portmap was started.
|
| 45 |
# This is to fix "hang" problems for new users who do not
|
| 46 |
# add portmap to the default runlevel.
|
| 47 |
if have_nfs && ! service_started "${pmap}" ; then
|
| 48 |
continue
|
| 49 |
fi
|
| 50 |
;;
|
| 51 |
esac
|
| 52 |
fs="${fs}${fs:+,}${x}"
|
| 53 |
done
|
| 54 |
|
| 55 |
ebegin "Mounting network filesystems"
|
| 56 |
mount -at ${fs}
|
| 57 |
ewend $? "Could not mount all network filesystems!"
|
| 58 |
return 0
|
| 59 |
}
|
| 60 |
|
| 61 |
stop() {
|
| 62 |
local x= fs=
|
| 63 |
for x in ${RC_NET_FS_LIST} ; do
|
| 64 |
fs="${fs}${fs:+,}${x}"
|
| 65 |
done
|
| 66 |
|
| 67 |
ebegin "Unmounting network filesystems"
|
| 68 |
umount -at ${fs}
|
| 69 |
local retval=$?
|
| 70 |
eend ${retval} "Failed to simply unmount filesystems"
|
| 71 |
|
| 72 |
if [ ${retval} -ne 0 ] ; then
|
| 73 |
. "${RC_LIBDIR}/sh/rc-mount.sh"
|
| 74 |
eindent
|
| 75 |
fs=
|
| 76 |
for x in ${RC_NET_FS_LIST} ; do
|
| 77 |
fs="${fs:+|}${x}"
|
| 78 |
done
|
| 79 |
do_unmount "umount" "" "" "^(${fs})$"
|
| 80 |
retval=$?
|
| 81 |
eoutdent
|
| 82 |
fi
|
| 83 |
|
| 84 |
return ${retval}
|
| 85 |
}
|
| 86 |
|
| 87 |
# vim: set ts=4 :
|