From 49df049f2cf45034cd8b11ab7d469a7d074b00da Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 16 Jun 2018 09:06:07 +0000 Subject: [PATCH] Change rauc mark handling --- .../hassos-supervisor.service.d/rauc.conf | 2 -- .../timers.target.wants/rauc-good.timer | 1 - .../timers.target.wants/rauc-mark.timer | 1 + .../lib/systemd/system/hassos-expand.service | 2 ++ .../usr/lib/systemd/system/rauc-bad.service | 10 ------- .../{rauc-good.service => rauc-mark.service} | 3 +-- .../{rauc-good.timer => rauc-mark.timer} | 0 .../usr/lib/systemd/system/zram-swap.service | 2 ++ .../usr/lib/systemd/system/zram-tmp.service | 2 ++ .../usr/lib/systemd/system/zram-var.service | 2 ++ .../rootfs-overlay/usr/sbin/hassos-rate | 26 +++++++++++++++++++ 11 files changed, 36 insertions(+), 15 deletions(-) delete mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-supervisor.service.d/rauc.conf delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-good.timer create mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-mark.timer delete mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-bad.service rename buildroot-external/rootfs-overlay/usr/lib/systemd/system/{rauc-good.service => rauc-mark.service} (58%) rename buildroot-external/rootfs-overlay/usr/lib/systemd/system/{rauc-good.timer => rauc-mark.timer} (100%) create mode 100755 buildroot-external/rootfs-overlay/usr/sbin/hassos-rate diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-supervisor.service.d/rauc.conf b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-supervisor.service.d/rauc.conf deleted file mode 100644 index e001464d1..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-supervisor.service.d/rauc.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Unit] -OnFailure=rauc-bad.service diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-good.timer b/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-good.timer deleted file mode 120000 index d010b7029..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-good.timer +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/rauc-good.timer \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-mark.timer b/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-mark.timer new file mode 120000 index 000000000..bbdfaf738 --- /dev/null +++ b/buildroot-external/rootfs-overlay/etc/systemd/system/timers.target.wants/rauc-mark.timer @@ -0,0 +1 @@ +/usr/lib/systemd/system/rauc-mark.timer \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service index b916789bf..cc50a0bf2 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service @@ -2,6 +2,8 @@ Description=HassOS data resizing DefaultDependencies=no Before=mnt-data.mount +RefuseManualStart=true +RefuseManualStop=true [Service] Type=oneshot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-bad.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-bad.service deleted file mode 100644 index baf737fe9..000000000 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-bad.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=HassOS rauc bad -Requires=rauc.service -RefuseManualStart=true -RefuseManualStop=true - -[Service] -Type=oneshot -ExecStart=/usr/bin/rauc status mark-bad -ExecStartPost=/usr/bin/systemctl reboot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-good.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-mark.service similarity index 58% rename from buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-good.service rename to buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-mark.service index 1e7935471..01d62f8c6 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-good.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-mark.service @@ -1,10 +1,9 @@ [Unit] Description=HassOS rauc good -Requires=hassos-supervisor.service rauc.service RefuseManualStart=true RefuseManualStop=true [Service] Type=oneshot -ExecStart=/usr/bin/rauc status mark-good +ExecStart=/usr/sbin/hassos-rate RemainAfterExit=true diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-good.timer b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-mark.timer similarity index 100% rename from buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-good.timer rename to buildroot-external/rootfs-overlay/usr/lib/systemd/system/rauc-mark.timer diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-swap.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-swap.service index 2f340f0d6..93cad3868 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-swap.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-swap.service @@ -2,6 +2,8 @@ Description=HassOS ZRAM swap DefaultDependencies=no Before=dev-zram0.swap +RefuseManualStart=true +RefuseManualStop=true [Service] Type=oneshot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-tmp.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-tmp.service index a7a6a5edc..b4e9d6862 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-tmp.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-tmp.service @@ -2,6 +2,8 @@ Description=HassOS ZRAM tmp DefaultDependencies=no Before=tmp.mount +RefuseManualStart=true +RefuseManualStop=true [Service] Type=oneshot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-var.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-var.service index 89640cd81..410f9b6fd 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-var.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/zram-var.service @@ -2,6 +2,8 @@ Description=HassOS ZRAM var DefaultDependencies=no Before=var.mount +RefuseManualStart=true +RefuseManualStop=true [Service] Type=oneshot diff --git a/buildroot-external/rootfs-overlay/usr/sbin/hassos-rate b/buildroot-external/rootfs-overlay/usr/sbin/hassos-rate new file mode 100755 index 000000000..4d79724df --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/sbin/hassos-rate @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + + +function mark_good() { + rauc status mark-good + exit 0 +} + +function mark_bad() { + rauc status mark-bad + exit 0 +} + +# Docker state +if ! systemctl -q is-active docker; then + mark_bad +fi + +# Docker state +if ! systemctl -q is-active hassos-supervisor; then + mark_bad +fi + +mark_good +