addon-vscode/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run
Richard Sperry bd9913b82b devenv
2025-04-17 13:09:22 -07:00

49 lines
1.8 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"
pathsfile="/etc/s6-overlay/s6-rc.d/paths.sh"
# shellcheck source=../paths.sh
source "${pathsfile}"
# List of previous config hashes, to allow upgrade "default" configs.
run() {
if [ ! -d "$CUSTOM_BASH_SCRIPTS_PATH" ]; then
bashio::log.warning "CUSTOM_BASH_SCRIPTS_PATH path does not exist. Creating..."
mkdir -p "$CUSTOM_BASH_SCRIPTS_PATH" ||
bashio::exit.nok "Could not create persistent storage folder."
fi
if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/custom-scripts.md ]]; then
bashio::log.warning "custom-scripts.md does not exist."
cp "$DEFAULT_FILES_PATH"/core/custom-scripts.md "$CUSTOM_BASH_SCRIPTS_PATH"/custom-scripts.md
fi
if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/custom-template.sh ]]; then
bashio::log.warning "custom-template.sh does not exist."
cp "$DEFAULT_FILES_PATH"/core/custom-template.sh "$CUSTOM_BASH_SCRIPTS_PATH"/custom-template.sh
fi
if [ ! -e "$USER_CUSTOM_DIR" ]; then
bashio::log.warning "USER_CUSTOM_DIR path does not exist. Creating..."
mkdir -p "$USER_CUSTOM_DIR" ||
bashio::exit.nok "Could not create persistent storage folder."
fi
if [ "$(ls -A "$CUSTOM_BASH_SCRIPTS_PATH")" ]; then
for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do
if [ "$script" = "$pathsfile" ]; then
continue
fi
echo "Running custom script: $script"
chmod +x "$script"
"$script"
done
fi
}
run