Debian Codegraph @

debian/src/initscripts/etc/init.d/umountroot

raw
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 and /usr filesystems read-only.
10 ### END INIT INFO
11
12 PATH=/sbin:/bin
13 . /lib/init/vars.sh
14
15 . /lib/lsb/init-functions
16
17 remount_ro() {
18 [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting $1 filesystem read-only"
19 MOUNT_FORCE_OPT=
20 [ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f
21 # This:
22 # mount -n -o remount,ro /
23 # will act on a bind mount of / if there is one.
24 # See #339023 and the comment in checkroot.sh
25 mount $MOUNT_FORCE_OPT -n -o remount,ro -t dummytype dummydev $2 2>/dev/null ||
26 mount $MOUNT_FORCE_OPT -n -o remount,ro dummydev $2 2>/dev/null ||
27 mount $MOUNT_FORCE_OPT -n -o remount,ro $2
28 ES=$?
29 [ "$VERBOSE" = no ] || log_action_end_msg $ES
30 }
31
32 do_stop() {
33 remount_ro root /
34 if mountpoint -q /usr; then
35 remount_ro /usr /usr
36 fi
37 }
38
39 case "$1" in
40 start | status)
41 # No-op
42 ;;
43 restart | reload | force-reload)
44 echo "Error: argument '$1' not supported" >&2
45 exit 3
46 ;;
47 stop)
48 do_stop
49 ;;
50 *)
51 echo "Usage: $0 start|stop" >&2
52 exit 3
53 ;;
54 esac
55
56 :