summaryrefslogtreecommitdiffstats
path: root/generic/lib/systemd/systemd-rc-once
blob: 5ecc5e5a3520bed20699ad0e513e27a1f1c6cd4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh

. /lib/init/initmethod-bbinit-functions.sh
. /lib/init/rc-once.sh

start() {
	mount_root_rw || exit 1
	if run_rc_once; then
		systemctl disable --quiet rc-once.target
	fi
	systemctl daemon-reexec
	sleep 1
	exec "$0" umount
}

umount() {
	if ! mount_root_restore; then
		# remounting rw/ro during the second boot will flush anything
		# left in the filesystem journal
		systemctl enable --quiet rc-once.target
		systemctl reboot
	else
		systemctl default
	fi
}

case "$1" in

	start|"")
		start
		;;
	umount)
		umount
		;;
	*)
		echo "Usage: $0 {start|umount}" >&2
		exit 1
		;;
esac

exit 0