#!/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" parent_dir=$(dirname "$(readlink -f "$0")") echo "$parent_dir" # shellcheck source=../paths.sh source "$parent_dir/paths.sh" # List of previous config hashes, to allow upgrade "default" configs. readonly CUSTOM_BASH_SCRIPTS_PATH="/data/custom" readonly DEFAULT_FILES_PATH="/var/lib/code-server/defaults/core" 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-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 if [ "$(ls -A "$CUSTOM_BASH_SCRIPTS_PATH")" ]; then for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do echo "Running custom script: $script" chmod +x "$script" "$script" done fi } run