PageRenderTime 100ms CodeModel.GetById 94ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/rc6.d/S60umountroot

http://github.com/brinkman83/bashrc
Shell | 62 lines | 33 code | 7 blank | 22 comment | 9 complexity | aa9aa9db438cc99f76b065827971ff42 MD5 | raw file
 1#! /bin/sh
 2### BEGIN INIT INFO
 3# Provides:          umountroot
 4# Required-Start:
 5# Required-Stop:
 6# Should-Stop:       halt reboot kexec
 7# Default-Start:
 8# Default-Stop:      0 6
 9# Short-Description: Mount the root filesystem read-only.
10### END INIT INFO
11
12PATH=/sbin:/bin
13. /lib/init/vars.sh
14
15. /lib/lsb/init-functions
16
17do_stop () {
18	[ "$VERBOSE" = no ] || log_action_begin_msg "Mounting root filesystem read-only"
19	# These directories must exist on the root filesystem as they are
20	# targets for system mountpoints.  We've just unmounted all other
21	# filesystems, so either they are mounted now (in which case the
22	# mount point exists) or we can make the mountpoint.
23	for dir in /proc /sys /var/run /var/lock; do
24	    mkdir -p $dir || true
25	done
26
27	# Ask init to reexec itself before we go down if it has been
28	# upgraded this cycle.  It'll lose all its state, but at least
29	# it won't hold open files on the root filesystem
30	[ -f /var/run/init.upgraded ] && telinit u || :
31
32	MOUNT_FORCE_OPT=
33	[ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f
34	# This:
35	#     mount -n -o remount,ro /
36	# will act on a bind mount of / if there is one.
37	# See #339023 and the comment in checkroot.sh
38	mount    $MOUNT_FORCE_OPT -n -o remount,ro -t dummytype dummydev / 2>/dev/null \
39	|| mount $MOUNT_FORCE_OPT -n -o remount,ro              dummydev / 2>/dev/null \
40	|| mount $MOUNT_FORCE_OPT -n -o remount,ro                       /
41	ES=$?
42	[ "$VERBOSE" = no ] || log_action_end_msg $ES
43}
44
45case "$1" in
46  start)
47	# No-op
48	;;
49  restart|reload|force-reload)
50	echo "Error: argument '$1' not supported" >&2
51	exit 3
52	;;
53  stop)
54	do_stop
55	;;
56  *)
57	echo "Usage: $0 start|stop" >&2
58	exit 3
59	;;
60esac
61
62: