Skip to content

Commit

Permalink
startup service: run scripts in /etc/s6-overlay/finish.d as down action
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Mar 21, 2024
1 parent 30f84d6 commit 21aa1e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/startup/down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/startup-finish
20 changes: 20 additions & 0 deletions rootfs/etc/s6-overlay/scripts/startup-finish
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 21aa1e3

Please sign in to comment.