🔨 Migrate old-style base scripts s6-rc (#546)

This commit is contained in:
Franck Nijhof 2022-12-13 21:43:12 +01:00 committed by GitHub
parent dc9c456ac7
commit c723527552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 43 additions and 13 deletions

View file

@ -0,0 +1,27 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Take down the S6 supervision tree when the code server 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="code-server"
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

View file

@ -1,12 +1,13 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Runs the code server
# Runs the code-server
# ==============================================================================
declare -a options
declare config_path
bashio::log.info 'Starting the code server...'
bashio::log.info 'Starting code-server...'
config_path="/config"
if bashio::config.has_value 'config_path'; then

View file

@ -0,0 +1 @@
longrun

View file

@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Sets up code-server.

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-code-server/run

View file

@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Pre-configures the Mosquitto clients, if the service is available

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mosquitto/run

View file

@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Pre-configures the MySQL clients, if the service is available

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mysql/run

View file

@ -1,4 +1,5 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Persists user settings and installs custom user packages.

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-user/run

View file

@ -1,11 +0,0 @@
#!/command/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Take down the S6 supervision tree when the code server fails
# ==============================================================================
if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then
bashio::log.warning "code-server crashed, halting add-on"
exec /run/s6/basedir/bin/halt
fi
bashio::log.info "code-server stopped, restarting..."