2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
2015-12-05 04:22:19 +05:30
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
2021-12-21 06:37:00 +05:30
|
|
|
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
2015-12-05 04:22:19 +05:30
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
2021-12-21 06:37:00 +05:30
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
2015-12-05 04:22:19 +05:30
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2014-10-02 03:44:25 +05:30
|
|
|
description="Mounts network shares according to /etc/fstab."
|
2012-09-11 02:13:42 +05:30
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
depend()
|
|
|
|
{
|
2015-12-09 03:32:31 +05:30
|
|
|
local opts mywant=""
|
|
|
|
for opts in $(fstabinfo -o -t nfs,nfs4); do
|
|
|
|
case $opts in
|
|
|
|
noauto) ;;
|
|
|
|
*) mywant="$mywant nfsclient"; break ;;
|
|
|
|
esac
|
|
|
|
done
|
2017-03-01 05:14:06 +05:30
|
|
|
after root
|
2015-12-09 03:32:31 +05:30
|
|
|
config /etc/fstab
|
2016-01-22 23:24:16 +05:30
|
|
|
want $mywant
|
2015-12-09 03:32:31 +05:30
|
|
|
use afc-client amd openvpn
|
2012-09-15 00:59:00 +05:30
|
|
|
use dns
|
2017-03-01 05:14:06 +05:30
|
|
|
use root
|
2016-07-31 23:31:17 +05:30
|
|
|
keyword -docker -jail -lxc -prefix -systemd-nspawn -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
|
|
|
{
|
2010-12-07 23:24:03 +05:30
|
|
|
local x= fs= rc=
|
2011-07-06 01:03:21 +05:30
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
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=$?
|
2016-04-15 22:00:44 +05:30
|
|
|
if [ "$RC_UNAME" = Linux ] && [ $rc = 0 ]; then
|
2015-10-02 03:46:14 +05:30
|
|
|
mount -a -O _netdev
|
|
|
|
rc=$?
|
|
|
|
fi
|
2010-12-07 23:24:03 +05:30
|
|
|
ewend $rc "Could not mount all network filesystems"
|
2016-04-25 22:34:34 +05:30
|
|
|
if [ -z "$critical_mounts" ]; then
|
2015-08-21 05:31:23 +05:30
|
|
|
rc=0
|
2016-04-25 22:34:34 +05:30
|
|
|
else
|
|
|
|
for x in ${critical_mounts}; do
|
2016-04-26 23:13:50 +05:30
|
|
|
fstabinfo -q $x || continue
|
|
|
|
if ! mountinfo -q $x; then
|
|
|
|
critical=x
|
|
|
|
eerror "Failed to mount $x"
|
|
|
|
fi
|
2016-04-25 22:34:34 +05:30
|
|
|
done
|
2016-04-26 23:13:50 +05:30
|
|
|
[ -z "$critical" ] && rc=0
|
2015-08-21 05:31:23 +05:30
|
|
|
fi
|
|
|
|
return $rc
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-07-06 01:03:21 +05:30
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
2014-10-02 03:44:25 +05:30
|
|
|
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=
|
2011-07-06 01:03:21 +05:30
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
2014-11-07 02:08:17 +05:30
|
|
|
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
|
2016-04-15 22:00:44 +05:30
|
|
|
if [ "$RC_UNAME" = Linux ] && [ $retval = 0 ]; then
|
2015-10-02 03:46:14 +05:30
|
|
|
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
|
|
|
}
|