Skip to content

Commit

Permalink
🔨 Migrate old-style base scripts s6-rc (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Dec 12, 2022
1 parent 7a6586e commit 1215369
Show file tree
Hide file tree
Showing 38 changed files with 73 additions and 22 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# shellcheck disable=SC2207
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Enables Docker by moving the Docker executable in place.
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-docker/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-docker/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-docker/run
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Pre-configures the Mosquitto clients, if the service is available
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-mosquitto/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-mosquitto/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mosquitto/run
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Pre-configures the MySQL clients, if the service is available
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-mysql/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-mysql/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mysql/run
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Configures the SSH daemon
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-ssh/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-ssh/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-ssh/run
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Executes configured customizations & persists user settings
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-user/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/init-user/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-user/run
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/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: SSH & Web Terminal
# Take down the S6 supervision tree when the SSH daemon 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="SSH"

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
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Starts the SSH service
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
26 changes: 26 additions & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/ttyd/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/command/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Take down the S6 supervision tree when the ttyd daemon 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="ttyd"

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
# ==============================================================================
# Home Assistant Community Add-on: SSH & Web Terminal
# Runs the ttyd daemon
Expand Down
1 change: 1 addition & 0 deletions ssh/rootfs/etc/s6-overlay/s6-rc.d/ttyd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 0 additions & 11 deletions ssh/rootfs/etc/services.d/sshd/finish

This file was deleted.

11 changes: 0 additions & 11 deletions ssh/rootfs/etc/services.d/ttyd/finish

This file was deleted.

0 comments on commit 1215369

Please sign in to comment.