the file doesnt have 99 lines.... ffs

This commit is contained in:
Richard Sperry 2025-04-14 21:32:32 -07:00
parent c1a04c4297
commit 45bf9d9507
24 changed files with 0 additions and 169 deletions

View file

@ -1,26 +0,0 @@
#!/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
# ==============================================================================
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 +0,0 @@
longrun

View file

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

View file

@ -1,28 +0,0 @@
#!/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
# ==============================================================================
declare host
declare password
declare port
declare username
if bashio::services.available "mqtt"; then
host=$(bashio::services "mqtt" "host")
password=$(bashio::services "mqtt" "password")
port=$(bashio::services "mqtt" "port")
username=$(bashio::services "mqtt" "username")
mkdir -p /root/.config
{
echo "-h ${host}"
echo "--pw ${password}"
echo "--port ${port}"
echo "--username ${username}"
} >/root/.config/mosquitto_sub
ln -s /root/.config/mosquitto_sub /root/.config/mosquitto_pub
ln -s /root/.config/mosquitto_sub /root/.config/mosquitto_rr
fi

View file

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

View file

@ -1,26 +0,0 @@
#!/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
# ==============================================================================
declare host
declare password
declare port
declare username
if bashio::services.available "mysql"; then
host=$(bashio::services "mysql" "host")
password=$(bashio::services "mysql" "password")
port=$(bashio::services "mysql" "port")
username=$(bashio::services "mysql" "username")
mkdir -p /root/.config
{
echo "[client]"
echo "host=${host}"
echo "password=\"${password}\""
echo "port=${port}"
echo "user=\"${username}\""
} > /etc/mysql/conf.d/service.cnf
fi

View file

@ -1 +0,0 @@
oneshot

View file

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

View file

@ -1,80 +0,0 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Persists user settings and installs custom user packages.
# ==============================================================================
readonly -a DIRECTORIES=(addon_configs addons backup homeassistant media share ssl)
readonly GIT_USER_PATH=/data/git
readonly SSH_USER_PATH=/data/.ssh
readonly ZSH_HISTORY_FILE=/root/.zsh_history
readonly ZSH_HISTORY_PERSISTANT_FILE=/data/.zsh_history
# Links some common directories to the user's home folder for convenience
for dir in "${DIRECTORIES[@]}"; do
ln -sn "/${dir}" "${HOME}/${dir}" \
|| bashio::log.warning "Failed linking common directory: ${dir}"
done
# Some links to old locations, to not mess with the user's muscle memory
ln -sn "/config" "${HOME}/config" \
|| bashio::log.warning "Failed linking common directory: ${HOME}/config"
ln -sn "/config" "/homeassistant" \
|| bashio::log.warning "Failed linking common directory: /homeassistant"
# Store SSH settings in add-on data folder
if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
mkdir -p "${SSH_USER_PATH}" \
|| bashio::exit.nok 'Failed to create a persistent .ssh folder'
chmod 700 "${SSH_USER_PATH}" \
|| bashio::exit.nok \
'Failed setting permissions on persistent .ssh folder'
fi
ln -sn "${SSH_USER_PATH}" ~/.ssh || bashio::log.warning "Failed linking .ssh"
# Sets up ZSH shell
touch "${ZSH_HISTORY_PERSISTANT_FILE}" \
|| bashio::exit.nok 'Failed creating a persistent ZSH history file'
chmod 600 "$ZSH_HISTORY_PERSISTANT_FILE" \
|| bashio::exit.nok \
'Failed setting the correct permissions to the ZSH history file'
ln -s -f "$ZSH_HISTORY_PERSISTANT_FILE" "$ZSH_HISTORY_FILE" \
|| bashio::exit.nok 'Failed linking the persistant ZSH history file'
# Store user GIT settings in add-on data folder
if ! bashio::fs.directory_exists "${GIT_USER_PATH}"; then
mkdir -p "${GIT_USER_PATH}" \
|| bashio::exit.nok 'Failed to create a persistent git folder'
chmod 700 "${GIT_USER_PATH}" \
|| bashio::exit.nok \
'Failed setting permissions on persistent git folder'
fi
if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
touch "${GIT_USER_PATH}/.gitconfig" \
|| bashio::exit.nok 'Failed to create .gitconfig'
fi
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig || bashio::log.warning "Failed linking .gitconfig"
# Install user configured/requested packages
if bashio::config.has_value 'packages'; then
apt update \
|| bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
for package in $(bashio::config 'packages'); do
apt-get install -y "$package" \
|| bashio::exit.nok "Failed installing package ${package}"
done
fi
# Executes user configured/requested commands on startup
if bashio::config.has_value 'init_commands'; then
while read -r cmd; do
eval "${cmd}" \
|| bashio::exit.nok "Failed executing init command: ${cmd}"
done <<< "$(bashio::config 'init_commands')"
fi

View file

@ -1 +0,0 @@
oneshot

View file

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