From b1543631512b4e56238b9ea8812f02d2a7e1cca3 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 22 Dec 2022 09:56:21 +0100 Subject: [PATCH] :hammer: Migrate old-style S6 scripts to s6-rc.d (#52) --- .../s6-rc.d/fah/dependencies.d/base | 0 .../rootfs/etc/s6-overlay/s6-rc.d/fah/finish | 27 +++++++++++++++++++ .../s6-rc.d}/fah/run | 1 + .../rootfs/etc/s6-overlay/s6-rc.d/fah/type | 1 + .../s6-overlay/s6-rc.d/user/contents.d/fah | 0 .../rootfs/etc/services.d/fah/finish | 11 -------- 6 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/dependencies.d/base create mode 100755 foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/finish rename foldingathome/rootfs/etc/{services.d => s6-overlay/s6-rc.d}/fah/run (96%) create mode 100644 foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/type create mode 100644 foldingathome/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/fah delete mode 100755 foldingathome/rootfs/etc/services.d/fah/finish diff --git a/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/dependencies.d/base b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/finish b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/finish new file mode 100755 index 0000000..5da8120 --- /dev/null +++ b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/finish @@ -0,0 +1,27 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Folding@home +# Take down the S6 supervision tree when FAHClient fails +# ============================================================================== +declare exit_code +readonly exit_code_container=$( /run/s6-linux-init-container-results/exitcode + fi + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + exec /run/s6/basedir/bin/halt +fi diff --git a/foldingathome/rootfs/etc/services.d/fah/run b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/run similarity index 96% rename from foldingathome/rootfs/etc/services.d/fah/run rename to foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/run index 1a7f598..cb50103 100755 --- a/foldingathome/rootfs/etc/services.d/fah/run +++ b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/run @@ -1,4 +1,5 @@ #!/command/with-contenv bashio +# shellcheck shell=bash # shellcheck disable=SC2191 # ============================================================================== # Home Assistant Community Add-on: Folding@home diff --git a/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/type b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/type @@ -0,0 +1 @@ +longrun diff --git a/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/fah b/foldingathome/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/fah new file mode 100644 index 0000000..e69de29 diff --git a/foldingathome/rootfs/etc/services.d/fah/finish b/foldingathome/rootfs/etc/services.d/fah/finish deleted file mode 100755 index 0b1468e..0000000 --- a/foldingathome/rootfs/etc/services.d/fah/finish +++ /dev/null @@ -1,11 +0,0 @@ -#!/command/with-contenv bashio -# ============================================================================== -# Home Assistant Community Add-on: Folding@home -# Take down the S6 supervision tree when FAHClient fails -# ============================================================================== -if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then - bashio::log.warning "FAHClient crashed, halting add-on" - /run/s6/basedir/bin/halt -fi - -bashio::log.info "FAHClient stopped, restarting..."