addon-vscode/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run
Richard Sperry c9d377307c devenv
2025-04-16 19:16:33 -07:00

32 lines
1.2 KiB
Text

#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Studio Code Server
# Sets up code-server.
# ==============================================================================
bashio::log.info "Initalizing code-server configs"
# List of previous config hashes, to allow upgrade "default" configs.
readonly CUSTOM_BASH_SCRIPTS_PATH="/data/vscode/custom"
readonly DEFAULT_FILES_PATH="/var/lib/code-server/defaults"
run() {
if [ ! -d "$CUSTOM_BASH_SCRIPTS_PATH" ]; then
bashio::log.warning "CUSTOM_BASH_SCRIPTS_PATH path did not exist, creating $CUSTOM_BASH_SCRIPTS_PATH"
mkdir -p "$CUSTOM_BASH_SCRIPTS_PATH" ||
bashio::exit.nok "Could not create persistent storage folder."
fi
if [[ ! -e "$DEFAULT_FILES_PATH"/custom-template.sh ]]; then
bashio::log.warning "custom-template.sh does not exist."
cp "$DEFAULT_FILES_PATH"/custom-template.sh "$CUSTOM_BASH_SCRIPTS_PATH"/custom-template.sh
fi
for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do
bashio::log.info "Config script: $script"
chmod +x "$script"
"$CUSTOM_BASH_SCRIPTS_PATH"/"$script"
done
}
run