Skip to content

Commit

Permalink
🔨 Migrate old-style S6 scripts to s6-rc.d (#52)
Browse files Browse the repository at this point in the history
frenck authored Dec 22, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9f28ab4 commit b154363
Showing 6 changed files with 29 additions and 11 deletions.
Empty file.
27 changes: 27 additions & 0 deletions foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/finish
Original file line number Diff line number Diff line change
@@ -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)
readonly exit_code_service="${1}"
readonly exit_code_signal="${2}"
readonly service="FAHClient"

bashio::log.info \
"Service ${service} exited with code ${exit_code_service}" \
"(by signal ${exit_code_signal})"

if [[ "${exit_code_service}" -eq 256 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo $((128 + $exit_code_signal)) > /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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# shellcheck disable=SC2191
# ==============================================================================
# Home Assistant Community Add-on: Folding@home
1 change: 1 addition & 0 deletions foldingathome/rootfs/etc/s6-overlay/s6-rc.d/fah/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
11 changes: 0 additions & 11 deletions foldingathome/rootfs/etc/services.d/fah/finish

This file was deleted.

0 comments on commit b154363

Please sign in to comment.