2013-12-21 14:51:11 -06:00
|
|
|
#!@SBINDIR@/openrc-run
|
2015-12-04 16:52:19 -06:00
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
|
|
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2008-11-03 15:31:01 +00:00
|
|
|
|
2008-11-03 16:16:12 +00:00
|
|
|
description="Re-mount filesytems read-only for a clean reboot."
|
|
|
|
|
2008-11-03 15:31:01 +00:00
|
|
|
depend()
|
|
|
|
{
|
|
|
|
need killprocs savecache
|
2015-04-28 21:03:49 -04:00
|
|
|
keyword -openvz -prefix -systemd-nspawn -vserver -lxc
|
2008-11-03 15:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
2012-08-18 22:37:15 +02:00
|
|
|
local ret=0
|
|
|
|
|
2008-11-03 15:31:01 +00:00
|
|
|
# Flush all pending disk writes now
|
2013-10-18 16:26:46 -05:00
|
|
|
sync
|
2008-11-03 15:31:01 +00:00
|
|
|
|
|
|
|
ebegin "Remounting remaining filesystems read-only"
|
|
|
|
# We need the do_unmount function
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
2008-11-03 15:31:01 +00:00
|
|
|
eindent
|
2011-09-11 15:12:54 +02:00
|
|
|
|
|
|
|
# Bug 381783
|
|
|
|
local rc_svcdir=$(echo $RC_SVCDIR | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g')
|
|
|
|
|
2012-05-02 14:40:16 -05:00
|
|
|
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs=
|
2011-09-11 15:12:54 +02:00
|
|
|
m="$m|/bin|/sbin|/lib(32|64)?|/libexec"
|
2008-11-03 15:31:01 +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
|
|
|
|
m="$m|$x"
|
2008-11-03 15:31:01 +00:00
|
|
|
done
|
2009-04-27 07:51:18 +00:00
|
|
|
m="^($m)$"
|
2008-11-03 15:31:01 +00:00
|
|
|
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"
|
2008-11-03 15:31:01 +00:00
|
|
|
done
|
2009-04-27 07:51:18 +00:00
|
|
|
[ -n "$fs" ] && fs="^($fs)$"
|
2008-11-04 11:30:15 +00:00
|
|
|
do_unmount "umount -r" \
|
2009-04-27 07:51:18 +00:00
|
|
|
--skip-point-regex "$m" \
|
2011-09-11 15:12:54 +02:00
|
|
|
"${fs:+--skip-fstype-regex}" $fs --nonetdev
|
2012-08-18 22:37:15 +02:00
|
|
|
ret=$?
|
|
|
|
|
2008-11-03 15:31:01 +00:00
|
|
|
eoutdent
|
2012-08-18 22:37:15 +02:00
|
|
|
|
|
|
|
eend $ret
|
2008-11-03 15:31:01 +00:00
|
|
|
}
|