From 21aa1e3a8335ed541ffe27339c0b9061d9f00157 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Wed, 20 Mar 2024 18:26:19 +0000 Subject: [PATCH] startup service: run scripts in /etc/s6-overlay/finish.d as down action --- rootfs/etc/s6-overlay/s6-rc.d/startup/down | 2 ++ rootfs/etc/s6-overlay/scripts/startup-finish | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/startup/down create mode 100755 rootfs/etc/s6-overlay/scripts/startup-finish diff --git a/rootfs/etc/s6-overlay/s6-rc.d/startup/down b/rootfs/etc/s6-overlay/s6-rc.d/startup/down new file mode 100755 index 0000000..2f14f7f --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/startup/down @@ -0,0 +1,2 @@ +#!/bin/sh +exec /etc/s6-overlay/scripts/startup-finish diff --git a/rootfs/etc/s6-overlay/scripts/startup-finish b/rootfs/etc/s6-overlay/scripts/startup-finish new file mode 100755 index 0000000..b8410cb --- /dev/null +++ b/rootfs/etc/s6-overlay/scripts/startup-finish @@ -0,0 +1,20 @@ +#!/command/with-contenv bash +# shellcheck shell=bash disable=SC1091,SC2076 + +source /scripts/common + +SDIR=/etc/s6-overlay/finish.d + +# exit 0 for nonexistent or empty directory +if ! [[ -d "$SDIR" ]] || [[ -z "$(ls "$SDIR")" ]]; then + exit 0 +fi + +cd "$SDIR" || exit 1 + +for NAME in *; do + if ! s6wrap --quiet --prepend="$NAME" --timestamps --args "$SDIR/$NAME"; then + s6wrap --quiet --prepend=startup --timestamps --args echo Error running "$SDIR/$NAME" + exit 1 + fi +done