summaryrefslogtreecommitdiffstats
path: root/projectroot/lib
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2015-06-11 12:18:01 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2015-06-18 16:22:13 +0200
commit28db1773524eb763569939d4066e32dbf50c69a0 (patch)
tree964e2f4165b48179d7ac39ac8d472788d60f99f0 /projectroot/lib
parent878707bd943a04fc8e3a55a151499359e81ce780 (diff)
downloadptxdist-28db1773524eb763569939d4066e32dbf50c69a0.tar.gz
ptxdist-28db1773524eb763569939d4066e32dbf50c69a0.tar.xz
generic: rename generic -> projectroot
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'projectroot/lib')
-rwxr-xr-xprojectroot/lib/init/initmethod-bbinit-functions.sh32
-rw-r--r--projectroot/lib/init/nm-unmanage.sh29
-rw-r--r--projectroot/lib/init/rc-once.sh25
-rwxr-xr-xprojectroot/lib/systemd/connman-ignore15
-rwxr-xr-xprojectroot/lib/systemd/ifupdown-prepare7
-rw-r--r--projectroot/lib/systemd/network/eth0.network5
-rw-r--r--projectroot/lib/systemd/system/NetworkManager-unmanage.service11
-rw-r--r--projectroot/lib/systemd/system/NetworkManager.service22
-rw-r--r--projectroot/lib/systemd/system/alfred@.service8
-rw-r--r--projectroot/lib/systemd/system/batadv-vis@.service9
-rw-r--r--projectroot/lib/systemd/system/collectd.service9
-rw-r--r--projectroot/lib/systemd/system/connman-ignore.service12
-rw-r--r--projectroot/lib/systemd/system/connman.service15
-rw-r--r--projectroot/lib/systemd/system/dnsmasq.service11
-rw-r--r--projectroot/lib/systemd/system/fake-overlayfs.service11
-rw-r--r--projectroot/lib/systemd/system/ifupdown-prepare.service11
-rw-r--r--projectroot/lib/systemd/system/ifupdown.service10
-rw-r--r--projectroot/lib/systemd/system/lighttpd.service10
-rw-r--r--projectroot/lib/systemd/system/munin-node.service11
-rw-r--r--projectroot/lib/systemd/system/nfs.target5
-rw-r--r--projectroot/lib/systemd/system/ntpd.service8
-rw-r--r--projectroot/lib/systemd/system/pure-ftpd.socket9
-rw-r--r--projectroot/lib/systemd/system/pure-ftpd@.service7
-rw-r--r--projectroot/lib/systemd/system/pure-uploadscript.service5
-rw-r--r--projectroot/lib/systemd/system/radvd.service7
-rw-r--r--projectroot/lib/systemd/system/rc-once.service13
-rw-r--r--projectroot/lib/systemd/system/rpc-statd.service10
-rw-r--r--projectroot/lib/systemd/system/sshd.socket9
-rw-r--r--projectroot/lib/systemd/system/sshd@.service8
-rw-r--r--projectroot/lib/systemd/system/telnetd.socket10
-rw-r--r--projectroot/lib/systemd/system/telnetd@.service7
-rw-r--r--projectroot/lib/systemd/system/urshd.service10
-rw-r--r--projectroot/lib/systemd/system/utelnetd.service9
-rw-r--r--projectroot/lib/systemd/systemd-rc-once48
34 files changed, 428 insertions, 0 deletions
diff --git a/projectroot/lib/init/initmethod-bbinit-functions.sh b/projectroot/lib/init/initmethod-bbinit-functions.sh
new file mode 100755
index 000000000..122e37883
--- /dev/null
+++ b/projectroot/lib/init/initmethod-bbinit-functions.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# generic functions for bbinit
+#
+
+mount_root_rw() {
+
+ touch "/.root_is_rw" > /dev/null 2>&1 && return
+
+ echo -n "remounting root rw..."
+ mount /dev/root / -n -o remount,rw > /dev/null 2>&1
+ if [ "$?" -ne "0" ]; then
+ echo "failed, aborting"
+ return 1
+ fi
+ echo "done"
+}
+
+mount_root_restore() {
+
+ rm "/.root_is_rw" > /dev/null 2>&1 && return
+
+ echo -n "remounting root ro..."
+ mount /dev/root / -n -o remount,ro > /dev/null 2>&1
+ if [ "$?" -ne "0" ]; then
+ echo "failed, aborting"
+ return 1
+ fi
+ echo "done"
+}
+
diff --git a/projectroot/lib/init/nm-unmanage.sh b/projectroot/lib/init/nm-unmanage.sh
new file mode 100644
index 000000000..c9944108d
--- /dev/null
+++ b/projectroot/lib/init/nm-unmanage.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# configure NM to regard already configured interfaces as unmanaged (for NFS root)
+
+CONFFILE=/var/run/NetworkManager.conf
+
+if [ ! -e /run/resolv.conf -a -e /proc/net/pnp ]; then
+ cp /proc/net/pnp /run/resolv.conf
+fi
+
+if [ ! -f $CONFFILE ]; then
+ # set previously enabled interfaces to unmanaged
+ cat /etc/NetworkManager/NetworkManager.conf > $CONFFILE
+
+ UNMANAGED=""
+ for IF in $(ls /sys/class/net); do
+ IF_FLAGS="$(cat /sys/class/net/$IF/flags)"
+ if [ "$((IF_FLAGS&1))" = "1" -a "$IF" != "lo" ]; then
+ IF_ADDR="$(cat /sys/class/net/$IF/address)"
+ UNMANAGED="$UNMANAGED;mac:$IF_ADDR"
+ fi
+ done
+
+ echo "" >> $CONFFILE
+ echo "[keyfile]" >> $CONFFILE
+ echo "# unmanaged-devices added by $0" >> $CONFFILE
+ echo "unmanaged-devices=${UNMANAGED:1}" >> $CONFFILE
+fi
+
diff --git a/projectroot/lib/init/rc-once.sh b/projectroot/lib/init/rc-once.sh
new file mode 100644
index 000000000..8689a32bc
--- /dev/null
+++ b/projectroot/lib/init/rc-once.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+RC_ONCE_DIR=/etc/rc.once.d
+DONE_DIR="$RC_ONCE_DIR/.done"
+STAMP="$DONE_DIR/rc-once"
+
+run_rc_once() {
+ failed=0
+ echo "running rc.once.d services..."
+ cd "$RC_ONCE_DIR" || exit 1
+ mkdir -p "$DONE_DIR"
+ for script in *; do
+ test -x "$script" || continue
+ test -e "$DONE_DIR/$script" && continue
+ "$RC_ONCE_DIR/$script"
+ if [ $? -ne 0 ]; then
+ echo "running $script failed."
+ failed=1
+ else
+ : > "$DONE_DIR/$script"
+ fi
+ done
+ return $failed
+}
+
diff --git a/projectroot/lib/systemd/connman-ignore b/projectroot/lib/systemd/connman-ignore
new file mode 100755
index 000000000..fe72c5567
--- /dev/null
+++ b/projectroot/lib/systemd/connman-ignore
@@ -0,0 +1,15 @@
+#!/bin/sh
+CONNMAN_IGNORE_OPTS=""
+for IF in $(ls /sys/class/net); do
+ IF_FLAGS="$(cat /sys/class/net/$IF/flags)"
+ if [ "$((IF_FLAGS&1))" = "1" -a "$IF" != "lo" ]; then
+ if [ -z "$CONNMAN_IGNORE_OPTS" ]; then
+ CONNMAN_IGNORE_OPTS="--nodevice=$IF"
+ else
+ CONNMAN_IGNORE_OPTS="$CONNMAN_IGNORE_OPTS,$IF"
+ fi
+ fi
+done
+
+echo "CONNMAN_IGNORE_OPTS=\"$CONNMAN_IGNORE_OPTS\"" > /run/connman-ignore
+
diff --git a/projectroot/lib/systemd/ifupdown-prepare b/projectroot/lib/systemd/ifupdown-prepare
new file mode 100755
index 000000000..2028749fb
--- /dev/null
+++ b/projectroot/lib/systemd/ifupdown-prepare
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ ! -e /run/resolv.conf -a -e /proc/net/pnp ]; then
+ cp /proc/net/pnp /run/resolv.conf
+fi
+
+ifconfig | awk '/^[^ ]/ { printf "%s=kernel\n", $1 }' > /var/run/ifstate
diff --git a/projectroot/lib/systemd/network/eth0.network b/projectroot/lib/systemd/network/eth0.network
new file mode 100644
index 000000000..0ac8a4f06
--- /dev/null
+++ b/projectroot/lib/systemd/network/eth0.network
@@ -0,0 +1,5 @@
+[Match]
+Name=eth0
+
+[Network]
+DHCP=v4
diff --git a/projectroot/lib/systemd/system/NetworkManager-unmanage.service b/projectroot/lib/systemd/system/NetworkManager-unmanage.service
new file mode 100644
index 000000000..9e41dc562
--- /dev/null
+++ b/projectroot/lib/systemd/system/NetworkManager-unmanage.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Network Manager configuration (ignore kernel activated network interfaces)
+Before=NetworkManager.service
+ConditionPathExists=!/var/run/NetworkManager.conf
+
+[Service]
+Type=oneshot
+ExecStart=/lib/init/nm-unmanage.sh
+
+[Install]
+WantedBy=NetworkManager.service
diff --git a/projectroot/lib/systemd/system/NetworkManager.service b/projectroot/lib/systemd/system/NetworkManager.service
new file mode 100644
index 000000000..f41c8b4bc
--- /dev/null
+++ b/projectroot/lib/systemd/system/NetworkManager.service
@@ -0,0 +1,22 @@
+[Unit]
+Description=Network Manager
+After=syslog.target
+Wants=network.target
+Before=network.target
+
+[Service]
+Type=dbus
+BusName=org.freedesktop.NetworkManager
+ExecStart=/usr/sbin/NetworkManager --no-daemon --config=/var/run/NetworkManager.conf --state-file=/var/run/NetworkManager.state
+# Suppress stderr to eliminate duplicated messages in syslog. NM calls openlog()
+# with LOG_PERROR when run in foreground. But systemd redirects stderr to
+# syslog by default, which results in logging each message twice.
+StandardError=null
+# NM doesn't want systemd to kill its children for it
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target
+Alias=dbus-org.freedesktop.NetworkManager.service
+Also=NetworkManager-wait-online.service
+
diff --git a/projectroot/lib/systemd/system/alfred@.service b/projectroot/lib/systemd/system/alfred@.service
new file mode 100644
index 000000000..08e014c41
--- /dev/null
+++ b/projectroot/lib/systemd/system/alfred@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description = A.L.F.R.E.D. server on interface %i
+BindsTo = sys-subsystem-net-devices-%i.device
+After = sys-subsystem-net-devices-%i.device
+
+[Service]
+ExecStart=/usr/bin/alfred -i %i
+
diff --git a/projectroot/lib/systemd/system/batadv-vis@.service b/projectroot/lib/systemd/system/batadv-vis@.service
new file mode 100644
index 000000000..39b4b6f34
--- /dev/null
+++ b/projectroot/lib/systemd/system/batadv-vis@.service
@@ -0,0 +1,9 @@
+[Unit]
+Description = batman-adv visualisation service on interface %i
+BindsTo = sys-subsystem-net-devices-%i.device
+After = sys-subsystem-net-devices-%i.device alfred@.service
+Requires = alfred@.service
+
+[Service]
+ExecStart=/usr/bin/batadv-vis -s -i %i
+
diff --git a/projectroot/lib/systemd/system/collectd.service b/projectroot/lib/systemd/system/collectd.service
new file mode 100644
index 000000000..752245c05
--- /dev/null
+++ b/projectroot/lib/systemd/system/collectd.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=statistics collection daemon
+
+[Service]
+ExecStart=/usr/sbin/collectd -f
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/connman-ignore.service b/projectroot/lib/systemd/system/connman-ignore.service
new file mode 100644
index 000000000..ac80f517c
--- /dev/null
+++ b/projectroot/lib/systemd/system/connman-ignore.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Connection Manager configuration (ignore kernel activated network interfaces)
+Before=connman.service
+ConditionPathExists=!/run/connman-ignore
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/lib/systemd/connman-ignore
+
+[Install]
+WantedBy=connman.service
diff --git a/projectroot/lib/systemd/system/connman.service b/projectroot/lib/systemd/system/connman.service
new file mode 100644
index 000000000..4353276b5
--- /dev/null
+++ b/projectroot/lib/systemd/system/connman.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Connection service
+Requires=dbus.socket
+After=dbus.socket
+
+[Service]
+Type=dbus
+BusName=net.connman
+Restart=on-failure
+EnvironmentFile=-/run/connman-ignore
+ExecStart=/usr/sbin/connmand -n $CONNMAN_IGNORE_OPTS
+StandardOutput=null
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/dnsmasq.service b/projectroot/lib/systemd/system/dnsmasq.service
new file mode 100644
index 000000000..c663e018c
--- /dev/null
+++ b/projectroot/lib/systemd/system/dnsmasq.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=dnsmasq
+
+[Service]
+ExecStart=/usr/sbin/dnsmasq --pid-file=/run/dnsmasq.pid
+ExecReload=/bin/kill -HUP $MAINPID
+Type=forking
+PIDFile=/run/dnsmasq.pid
+
+[Install]
+WantedBy=network.target
diff --git a/projectroot/lib/systemd/system/fake-overlayfs.service b/projectroot/lib/systemd/system/fake-overlayfs.service
new file mode 100644
index 000000000..efb4470e3
--- /dev/null
+++ b/projectroot/lib/systemd/system/fake-overlayfs.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Fake Overlay Filesystem
+DefaultDependencies=no
+After=local-fs.target
+Requires=local-fs.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/sbin/fake-overlayfs
+MountFlags=private
diff --git a/projectroot/lib/systemd/system/ifupdown-prepare.service b/projectroot/lib/systemd/system/ifupdown-prepare.service
new file mode 100644
index 000000000..2c2c43b8f
--- /dev/null
+++ b/projectroot/lib/systemd/system/ifupdown-prepare.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Mark kernel activated network interfaces as up
+Before=ifupdown.service
+ConditionPathExists=!/var/run/ifstate
+#ConditionKernelCommandLine=nfsroot
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/lib/systemd/ifupdown-prepare
+
diff --git a/projectroot/lib/systemd/system/ifupdown.service b/projectroot/lib/systemd/system/ifupdown.service
new file mode 100644
index 000000000..f9dd5b473
--- /dev/null
+++ b/projectroot/lib/systemd/system/ifupdown.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Handle network interface with ifup/ifdown
+Before=network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/ifup -a
+ExecStop=/sbin/ifdown -a
+
diff --git a/projectroot/lib/systemd/system/lighttpd.service b/projectroot/lib/systemd/system/lighttpd.service
new file mode 100644
index 000000000..0ca5357f5
--- /dev/null
+++ b/projectroot/lib/systemd/system/lighttpd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Lighttpd Web Server
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/lighttpd-angel -f /etc/lighttpd/lighttpd.conf -D
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/munin-node.service b/projectroot/lib/systemd/system/munin-node.service
new file mode 100644
index 000000000..8bb98ceef
--- /dev/null
+++ b/projectroot/lib/systemd/system/munin-node.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Munin Node
+
+[Service]
+Type=forking
+Restart=always
+ExecStart=/usr/sbin/munin-node
+PIDFile=/run/munin-node.pid
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/nfs.target b/projectroot/lib/systemd/system/nfs.target
new file mode 100644
index 000000000..ea1b87c9c
--- /dev/null
+++ b/projectroot/lib/systemd/system/nfs.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=NFS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/ntpd.service b/projectroot/lib/systemd/system/ntpd.service
new file mode 100644
index 000000000..64fce1cb7
--- /dev/null
+++ b/projectroot/lib/systemd/system/ntpd.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=ntpd
+
+[Service]
+ExecStart=/usr/sbin/ntpd -n -c /etc/ntp-server.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/pure-ftpd.socket b/projectroot/lib/systemd/system/pure-ftpd.socket
new file mode 100644
index 000000000..1883b579f
--- /dev/null
+++ b/projectroot/lib/systemd/system/pure-ftpd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Conflicts=pure-ftpd.service
+
+[Socket]
+ListenStream=21
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
diff --git a/projectroot/lib/systemd/system/pure-ftpd@.service b/projectroot/lib/systemd/system/pure-ftpd@.service
new file mode 100644
index 000000000..b7f086731
--- /dev/null
+++ b/projectroot/lib/systemd/system/pure-ftpd@.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=pure-ftpd
+After=syslog.target
+@SCRIPT_DEPS@
+[Service]
+ExecStart=/usr/sbin/pure-ftpd @ARGS@
+StandardInput=socket
diff --git a/projectroot/lib/systemd/system/pure-uploadscript.service b/projectroot/lib/systemd/system/pure-uploadscript.service
new file mode 100644
index 000000000..9cdbebc07
--- /dev/null
+++ b/projectroot/lib/systemd/system/pure-uploadscript.service
@@ -0,0 +1,5 @@
+[Unit]
+Description=pure-ftpd upload script helper
+
+[Service]
+ExecStart=/usr/sbin/pure-uploadscript @ARGS@ -r @SCRIPT@
diff --git a/projectroot/lib/systemd/system/radvd.service b/projectroot/lib/systemd/system/radvd.service
new file mode 100644
index 000000000..d3c7d98aa
--- /dev/null
+++ b/projectroot/lib/systemd/system/radvd.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=IPv6 router advertisement daemon
+Requires=network.target
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/radvd -C /etc/radvd.conf --nodaemon --username nobody
diff --git a/projectroot/lib/systemd/system/rc-once.service b/projectroot/lib/systemd/system/rc-once.service
new file mode 100644
index 000000000..d3377b3d7
--- /dev/null
+++ b/projectroot/lib/systemd/system/rc-once.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=First boot services
+DefaultDependencies=no
+After=local-fs.target
+Requires=local-fs.target
+After=system-update.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/lib/systemd/systemd-rc-once
+StandardOutput=syslog+console
+
diff --git a/projectroot/lib/systemd/system/rpc-statd.service b/projectroot/lib/systemd/system/rpc-statd.service
new file mode 100644
index 000000000..3c2bb2c71
--- /dev/null
+++ b/projectroot/lib/systemd/system/rpc-statd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=NFS status monitor for NFSv2/3 locking.
+DefaultDependencies=no
+Conflicts=umount.target
+Requires=nss-lookup.target rpcbind.target
+After=network.target nss-lookup.target rpcbind.target
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/rpc.statd --no-notify
diff --git a/projectroot/lib/systemd/system/sshd.socket b/projectroot/lib/systemd/system/sshd.socket
new file mode 100644
index 000000000..fd684073d
--- /dev/null
+++ b/projectroot/lib/systemd/system/sshd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Conflicts=sshd.service
+
+[Socket]
+ListenStream=22
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
diff --git a/projectroot/lib/systemd/system/sshd@.service b/projectroot/lib/systemd/system/sshd@.service
new file mode 100644
index 000000000..a96f28680
--- /dev/null
+++ b/projectroot/lib/systemd/system/sshd@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=SSH Per-Connection Server
+After=syslog.target
+
+[Service]
+ExecStart=/usr/sbin/sshd -i
+SuccessExitStatus=0 255
+StandardInput=socket
diff --git a/projectroot/lib/systemd/system/telnetd.socket b/projectroot/lib/systemd/system/telnetd.socket
new file mode 100644
index 000000000..22441383d
--- /dev/null
+++ b/projectroot/lib/systemd/system/telnetd.socket
@@ -0,0 +1,10 @@
+[Unit]
+Conflicts=telnetd.service
+ConditionKernelCommandLine=ptxdist-devel
+
+[Socket]
+ListenStream=23
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
diff --git a/projectroot/lib/systemd/system/telnetd@.service b/projectroot/lib/systemd/system/telnetd@.service
new file mode 100644
index 000000000..e0897eb00
--- /dev/null
+++ b/projectroot/lib/systemd/system/telnetd@.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Telnet Per-Connection Server
+After=syslog.target
+
+[Service]
+ExecStart=/usr/sbin/telnetd -i
+StandardInput=socket
diff --git a/projectroot/lib/systemd/system/urshd.service b/projectroot/lib/systemd/system/urshd.service
new file mode 100644
index 000000000..913256583
--- /dev/null
+++ b/projectroot/lib/systemd/system/urshd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=urshd Server
+After=syslog.target
+ConditionKernelCommandLine=ptxdist-devel
+
+[Service]
+ExecStart=/usr/bin/urshd -D
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/system/utelnetd.service b/projectroot/lib/systemd/system/utelnetd.service
new file mode 100644
index 000000000..406f994ab
--- /dev/null
+++ b/projectroot/lib/systemd/system/utelnetd.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Telnet Server
+After=syslog.target
+
+[Service]
+ExecStart=/sbin/utelnetd
+
+[Install]
+WantedBy=multi-user.target
diff --git a/projectroot/lib/systemd/systemd-rc-once b/projectroot/lib/systemd/systemd-rc-once
new file mode 100644
index 000000000..98b089185
--- /dev/null
+++ b/projectroot/lib/systemd/systemd-rc-once
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. /lib/init/initmethod-bbinit-functions.sh
+. /lib/init/rc-once.sh
+
+start() {
+ mount_root_rw || exit 1
+ if run_rc_once; then
+ rm -f /system-update
+ fi
+ systemctl daemon-reexec
+ sleep 1
+ touch /var/lib/systemd/clock
+ exec "$0" umount
+}
+
+umount() {
+ if ! mount_root_restore; then
+ # remounting rw/ro during the second boot will flush anything
+ # left in the filesystem journal
+ ln -sf /etc/rc.once.d /system-update
+ systemctl reboot
+ else
+ if [ -e /system-update ]; then
+ systemctl rescue
+ else
+ systemctl default
+ fi
+ fi
+}
+
+case "$1" in
+
+ start|"")
+ start
+ ;;
+ umount)
+ umount
+ ;;
+ *)
+ echo "Usage: $0 {start|umount}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+