From e6e846adf361dd8a487f0b89623f239733742f98 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 28 Sep 2022 09:44:01 +0200 Subject: [hardware-stats] Try harder to submit shutdown event to slx-admin --- .../system/shutdown.target.wants/stats-shutdown.service | 1 + .../data/etc/systemd/system/stats-shutdown.service | 13 +++++++++++++ .../data/opt/openslx/scripts/shutdown-system_usage_update | 6 +++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 120000 core/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/stats-shutdown.service create mode 100644 core/modules/hardware-stats/data/etc/systemd/system/stats-shutdown.service (limited to 'core/modules/hardware-stats') diff --git a/core/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/stats-shutdown.service b/core/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/stats-shutdown.service new file mode 120000 index 00000000..35ac58a7 --- /dev/null +++ b/core/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/stats-shutdown.service @@ -0,0 +1 @@ +../stats-shutdown.service \ No newline at end of file diff --git a/core/modules/hardware-stats/data/etc/systemd/system/stats-shutdown.service b/core/modules/hardware-stats/data/etc/systemd/system/stats-shutdown.service new file mode 100644 index 00000000..5d36034a --- /dev/null +++ b/core/modules/hardware-stats/data/etc/systemd/system/stats-shutdown.service @@ -0,0 +1,13 @@ +[Unit] +Description=Send shutdown event to boot server +# Try this as a dedicated service in addition to the ExecStop= +# entry in the hardware-stats.service, as that one sometimes +# doesn't trigger/reach the server :-( +Wants=network.target +Before=shutdown.target +After=network.target + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/shutdown-system_usage_update + diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update index 31ac01a3..6df22843 100755 --- a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update +++ b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update @@ -1,5 +1,8 @@ #!/bin/ash +# Already done/running? Consider success +mkdir /run/openslx/shutdown.mutex || exit 0 + . /opt/openslx/config [ -z "$SLX_REMOTE_LOG" ] && exit 0 @@ -7,6 +10,7 @@ UUID=$(cat /etc/system-uuid) [ -z "$UUID" ] && exit 1 -curl --retry 3 --retry-connrefused --max-time 3 --retry-max-time 10 -s --data-urlencode "type=~poweroff" --data-urlencode "uuid=$UUID" \ +curl --retry 3 --retry-connrefused --max-time 3 --retry-max-time 10 -s \ + --data-urlencode "type=~poweroff" --data-urlencode "uuid=$UUID" \ "$SLX_REMOTE_LOG" -- cgit v1.2.3-55-g7522