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.
|
2008-11-03 21:01:01 +05:30
|
|
|
|
2022-04-15 21:23:24 +05:30
|
|
|
description="Re-mount filesystems read-only for a clean reboot."
|
2008-11-03 21:46:12 +05:30
|
|
|
|
2008-11-03 21:01:01 +05:30
|
|
|
depend()
|
|
|
|
{
|
2017-04-01 00:09:42 +05:30
|
|
|
after killprocs savecache
|
2016-07-31 23:31:17 +05:30
|
|
|
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
|
2008-11-03 21:01:01 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
2012-08-19 02:07:15 +05:30
|
|
|
local ret=0
|
|
|
|
|
2008-11-03 21:01:01 +05:30
|
|
|
# Flush all pending disk writes now
|
2013-10-19 02:56:46 +05:30
|
|
|
sync
|
2008-11-03 21:01:01 +05:30
|
|
|
|
|
|
|
ebegin "Remounting remaining filesystems read-only"
|
|
|
|
# We need the do_unmount function
|
2009-05-24 01:08:12 +05:30
|
|
|
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
2008-11-03 21:01:01 +05:30
|
|
|
eindent
|
2011-09-11 18:42:54 +05:30
|
|
|
|
|
|
|
# Bug 381783
|
|
|
|
local rc_svcdir=$(echo $RC_SVCDIR | sed 's:/lib\(32\|64\)\?/:/lib(32|64)?/:g')
|
|
|
|
|
2012-05-03 01:10:16 +05:30
|
|
|
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs=
|
2011-09-11 18:42:54 +05:30
|
|
|
m="$m|/bin|/sbin|/lib(32|64)?|/libexec"
|
2016-11-03 22:59:21 +05:30
|
|
|
if [ -e "$rc_svcdir"/usr_premounted ]; then
|
|
|
|
m="$m|/usr"
|
|
|
|
fi
|
2008-11-03 21:01:01 +05:30
|
|
|
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
2011-07-07 22:21:39 +05:30
|
|
|
local IFS="$IFS:"
|
2009-04-27 13:21:18 +05:30
|
|
|
for x in $no_umounts $RC_NO_UMOUNTS; do
|
|
|
|
m="$m|$x"
|
2008-11-03 21:01:01 +05:30
|
|
|
done
|
2009-04-27 13:21:18 +05:30
|
|
|
m="^($m)$"
|
2008-11-03 21:01:01 +05:30
|
|
|
fs=
|
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"
|
2008-11-03 21:01:01 +05:30
|
|
|
done
|
2009-04-27 13:21:18 +05:30
|
|
|
[ -n "$fs" ] && fs="^($fs)$"
|
2008-11-04 17:00:15 +05:30
|
|
|
do_unmount "umount -r" \
|
2009-04-27 13:21:18 +05:30
|
|
|
--skip-point-regex "$m" \
|
2011-09-11 18:42:54 +05:30
|
|
|
"${fs:+--skip-fstype-regex}" $fs --nonetdev
|
2012-08-19 02:07:15 +05:30
|
|
|
ret=$?
|
|
|
|
|
2008-11-03 21:01:01 +05:30
|
|
|
eoutdent
|
2012-08-19 02:07:15 +05:30
|
|
|
|
|
|
|
eend $ret
|
2008-11-03 21:01:01 +05:30
|
|
|
}
|