From 0ed97fd0c9a2d6114c10e7e7ece2afbca4536d1f Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 14 Dec 2022 22:30:53 +0100 Subject: [PATCH] :hammer: Migrate old-style base scripts s6-rc (#163) --- .../s6-rc.d/init-zerotier/dependencies.d/base | 0 .../s6-rc.d/init-zerotier/run} | 1 + .../etc/s6-overlay/s6-rc.d/init-zerotier/type | 1 + .../etc/s6-overlay/s6-rc.d/init-zerotier/up | 1 + .../s6-rc.d/user/contents.d/init-zerotier | 0 .../s6-rc.d/user/contents.d/zerotier | 0 .../zerotier/dependencies.d/init-zerotier | 0 .../etc/s6-overlay/s6-rc.d/zerotier/finish | 27 +++++++++++++++++++ .../s6-rc.d}/zerotier/run | 1 + .../etc/s6-overlay/s6-rc.d/zerotier/type | 1 + .../rootfs/etc/services.d/zerotier/finish | 11 -------- 11 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/dependencies.d/base rename zerotier/rootfs/etc/{cont-init.d/zerotier.sh => s6-overlay/s6-rc.d/init-zerotier/run} (98%) create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/type create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/up create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-zerotier create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/zerotier create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/dependencies.d/init-zerotier create mode 100755 zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/finish rename zerotier/rootfs/etc/{services.d => s6-overlay/s6-rc.d}/zerotier/run (95%) create mode 100644 zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/type delete mode 100755 zerotier/rootfs/etc/services.d/zerotier/finish diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/dependencies.d/base b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/zerotier/rootfs/etc/cont-init.d/zerotier.sh b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/run similarity index 98% rename from zerotier/rootfs/etc/cont-init.d/zerotier.sh rename to zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/run index a005303..370d17a 100755 --- a/zerotier/rootfs/etc/cont-init.d/zerotier.sh +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/run @@ -1,4 +1,5 @@ #!/command/with-contenv bashio +# shellcheck shell=bash # ============================================================================== # Home Assistant Community Add-on: ZeroTier One # Generates an identiy in case it does not exists yet diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/type b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/type @@ -0,0 +1 @@ +oneshot diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/up b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/up new file mode 100644 index 0000000..bef0a09 --- /dev/null +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/init-zerotier/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-zerotier/run diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-zerotier b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-zerotier new file mode 100644 index 0000000..e69de29 diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/zerotier b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/zerotier new file mode 100644 index 0000000..e69de29 diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/dependencies.d/init-zerotier b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/dependencies.d/init-zerotier new file mode 100644 index 0000000..e69de29 diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/finish b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/finish new file mode 100755 index 0000000..804d21a --- /dev/null +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/finish @@ -0,0 +1,27 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: ZeroTier One +# Take down the S6 supervision tree when ZeroTier 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/zerotier/rootfs/etc/services.d/zerotier/run b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/run similarity index 95% rename from zerotier/rootfs/etc/services.d/zerotier/run rename to zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/run index 2866cfc..e5e5c9e 100755 --- a/zerotier/rootfs/etc/services.d/zerotier/run +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/run @@ -1,4 +1,5 @@ #!/command/with-contenv bashio +# shellcheck shell=bash # ============================================================================== # Home Assistant Community Add-on: ZeroTier One # Runs ZeroTier One diff --git a/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/type b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/zerotier/rootfs/etc/s6-overlay/s6-rc.d/zerotier/type @@ -0,0 +1 @@ +longrun diff --git a/zerotier/rootfs/etc/services.d/zerotier/finish b/zerotier/rootfs/etc/services.d/zerotier/finish deleted file mode 100755 index dd03827..0000000 --- a/zerotier/rootfs/etc/services.d/zerotier/finish +++ /dev/null @@ -1,11 +0,0 @@ -#!/command/with-contenv bashio -# ============================================================================== -# Home Assistant Community Add-on: ZeroTier One -# Take down the S6 supervision tree when ZeroTier fails -# ============================================================================== -if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then - bashio::log.warning "ZeroTier crashed, halting add-on" - /run/s6/basedir/bin/halt -fi - -bashio::log.info "ZeroTier stopped, restarting..."