2008-03-02 21:14:01 +00:00
|
|
|
#!@PREFIX@/sbin/runscript
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2008-01-11 15:31:10 +00:00
|
|
|
# All rights reserved. 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
|
2009-11-04 19:21:24 +00: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=
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $net_fs_list; do
|
2007-04-05 11:18:42 +00:00
|
|
|
types="${types},${x}"
|
|
|
|
done
|
|
|
|
|
2010-11-30 15:40:44 -06:00
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
no_netdev="-O no_netdev"
|
|
|
|
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()
|
|
|
|
{
|
2007-10-05 13:37:57 +00:00
|
|
|
# We never unmount / or /dev or $RC_SVCDIR
|
2008-07-09 16:08:38 +00:00
|
|
|
local x= no_umounts_r="/|/dev|/dev/.*|${RC_SVCDIR}"
|
2009-04-16 23:34:38 +00:00
|
|
|
no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib|/libexec"
|
2007-11-23 12:04:11 +00:00
|
|
|
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
2009-04-27 07:51:18 +00:00
|
|
|
OIFS=$IFS SIFS=${IFS-y}
|
2007-04-05 11:18:42 +00:00
|
|
|
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 [ "$SIFS" = y ]; then
|
2007-04-05 11:18:42 +00:00
|
|
|
IFS=$OIFS
|
|
|
|
else
|
|
|
|
unset IFS
|
|
|
|
fi
|
|
|
|
|
2009-04-27 07:51:18 +00:00
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/sys|/sys/.*"
|
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
|
|
|
|
|
|
|
# Umount loopback devices
|
|
|
|
einfo "Unmounting loopback devices"
|
|
|
|
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=
|
2009-04-27 07:51:18 +00:00
|
|
|
for x in $net_fs_list; do
|
|
|
|
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" \
|
|
|
|
${fs:+--skip-fstype-regex} $fs --nonetdev
|
2007-04-05 11:18:42 +00:00
|
|
|
eoutdent
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|