2013-02-12 17:09:50 -05:00
|
|
|
#!@SBINDIR@/runscript
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-29 19:46:31 -04:00
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2007-07-10 19:09:41 +00:00
|
|
|
description="Mounts disks and swap according to /etc/fstab."
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
depend()
|
|
|
|
{
|
2008-01-31 16:10:18 +00:00
|
|
|
need fsck
|
2008-03-05 08:40:17 +00:00
|
|
|
use lvm modules mtab
|
2010-12-11 14:25:46 -08:00
|
|
|
after lvm modules
|
2012-07-02 22:04:22 -05:00
|
|
|
keyword -jail -openvz -prefix -vserver -lxc
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
start()
|
|
|
|
{
|
2007-04-05 11:18:42 +00:00
|
|
|
# Mount local filesystems in /etc/fstab.
|
2010-11-30 15:40:44 -06:00
|
|
|
local types="noproc" x= no_netdev=
|
2011-07-05 14:33:21 -05:00
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
2013-03-22 14:50:27 -05:00
|
|
|
types="${types},no${x}"
|
2007-04-05 11:18:42 +00:00
|
|
|
done
|
|
|
|
|
2010-11-30 15:40:44 -06:00
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
no_netdev="-O no_netdev"
|
2012-11-30 12:05:26 -06:00
|
|
|
if mountinfo -q /usr; then
|
2012-12-16 20:00:01 -06:00
|
|
|
touch "$RC_SVCDIR"/usr_premounted
|
2012-11-29 10:19:20 -06:00
|
|
|
fi
|
2010-11-30 15:40:44 -06:00
|
|
|
fi
|
2007-04-05 11:18:42 +00:00
|
|
|
ebegin "Mounting local filesystems"
|
2010-11-30 15:40:44 -06:00
|
|
|
mount -at "$types" $no_netdev
|
2007-04-05 11:18:42 +00:00
|
|
|
eend $? "Some local filesystem failed to mount"
|
|
|
|
|
|
|
|
# Always return 0 - some local mounts may not be critical for boot
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2008-01-11 12:13:46 +00:00
|
|
|
stop()
|
|
|
|
{
|
2012-03-25 18:29:37 -05:00
|
|
|
yesno $RC_GOINGDOWN || return 0
|
2007-10-05 13:37:57 +00:00
|
|
|
# We never unmount / or /dev or $RC_SVCDIR
|
2011-09-11 15:12:54 +02:00
|
|
|
|
|
|
|
# Bug 381783
|
2012-12-16 20:00:01 -06:00
|
|
|
local rc_svcdir=$(printf '%s\n' "$RC_SVCDIR" | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g')
|
2011-09-11 15:12:54 +02:00
|
|
|
|
|
|
|
local x= no_umounts_r="/|/dev|/dev/.*|${rc_svcdir}"
|
|
|
|
no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib(32|64)?|/libexec"
|
2007-11-23 12:04:11 +00:00
|
|
|
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
2011-07-07 11:51:39 -05:00
|
|
|
local IFS="$IFS:"
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $no_umounts $RC_NO_UMOUNTS; do
|
|
|
|
no_umounts_r="$no_umounts_r|$x"
|
2007-04-05 11:18:42 +00:00
|
|
|
done
|
|
|
|
|
2009-04-27 07:51:18 +00:00
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
2012-11-29 10:19:20 -06:00
|
|
|
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
|
2012-12-16 20:00:01 -06:00
|
|
|
if [ -e "$rc_svcdir"/usr_premounted ]; then
|
2012-11-29 10:19:20 -06:00
|
|
|
no_umounts_r="$no_umounts_r|/usr"
|
|
|
|
fi
|
2007-04-05 11:18:42 +00:00
|
|
|
fi
|
2009-04-27 07:51:18 +00:00
|
|
|
no_umounts_r="^($no_umounts_r)$"
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# Flush all pending disk writes now
|
2007-11-23 12:04:11 +00:00
|
|
|
sync; sync
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2011-02-14 04:41:08 -05:00
|
|
|
# Umount loop devices
|
|
|
|
einfo "Unmounting loop devices"
|
2007-04-05 11:18:42 +00:00
|
|
|
eindent
|
2009-04-27 07:51:18 +00:00
|
|
|
do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \
|
2007-10-09 15:33:05 +00:00
|
|
|
--node-regex "^/dev/loop"
|
2007-04-05 11:18:42 +00:00
|
|
|
eoutdent
|
|
|
|
|
2007-07-11 17:27:46 +00:00
|
|
|
# Now everything else, except network filesystems as the
|
|
|
|
# network should be down by this point.
|
2007-04-05 11:18:42 +00:00
|
|
|
einfo "Unmounting filesystems"
|
|
|
|
eindent
|
2007-07-11 17:27:46 +00:00
|
|
|
local fs=
|
2011-07-05 14:33:21 -05:00
|
|
|
for x in $net_fs_list $extra_net_fs_list; do
|
2009-04-27 07:51:18 +00:00
|
|
|
fs="$fs${fs:+|}$x"
|
2007-07-11 17:27:46 +00:00
|
|
|
done
|
2009-04-27 07:51:18 +00:00
|
|
|
[ -n "$fs" ] && fs="^($fs)$"
|
|
|
|
do_unmount umount --skip-point-regex "$no_umounts_r" \
|
2011-09-11 15:12:54 +02:00
|
|
|
"${fs:+--skip-fstype-regex}" $fs --nonetdev
|
2007-04-05 11:18:42 +00:00
|
|
|
eoutdent
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|