diff --git a/vscode/Dockerfile b/vscode/Dockerfile index 818d7b0..b296d48 100644 --- a/vscode/Dockerfile +++ b/vscode/Dockerfile @@ -25,6 +25,7 @@ RUN apt-get update \ && apt-get full-upgrade -y \ && apt-get install -y --no-install-recommends \ ack \ + direnv \ libarchive-tools \ colordiff \ git \ diff --git a/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run b/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run index c0f7cd9..b039109 100644 --- a/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run +++ b/vscode/rootfs/etc/s6-overlay/s6-rc.d/init-custom-bash/run @@ -4,36 +4,27 @@ # Home Assistant Community Add-on: Studio Code Server # Sets up code-server. # ============================================================================== -bashio::log.info "Initalizing code-server configs" +bashio::log.info "Initalizing custom-bash" + 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 + setup + run_boot_scripts +} - 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 +core_file_copy() { + local fname=${1} - if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/example-mqtt.sh ]]; then - bashio::log.warning "example-mqtt.sh does not exist." - cp "$DEFAULT_FILES_PATH"/core/example-mqtt.sh "$CUSTOM_BASH_SCRIPTS_PATH"/example-mqtt.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." + if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/"$fname" ]]; then + bashio::log.warning "$fname does not exist." + cp "$DEFAULT_FILES_PATH"/core/"$fname" "$CUSTOM_BASH_SCRIPTS_PATH"/"$fname" fi +} +run_boot_scripts() { if [ "$(ls -A "$CUSTOM_BASH_SCRIPTS_PATH")" ]; then for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do if [ "$script" = "$pathsfile" ]; then @@ -46,4 +37,24 @@ run() { fi } +setup() { + # Base Dir + 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 + + # Copy default files + core_file_copy "custom-scripts.md" + core_file_copy "example-mqtt.sh" + core_file_copy "TASK_HELPER.sh" + + 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 +} + run diff --git a/vscode/rootfs/var/lib/code-server/defaults/core/TASK_HELPER.sh b/vscode/rootfs/var/lib/code-server/defaults/core/TASK_HELPER.sh new file mode 100644 index 0000000..b23bee7 --- /dev/null +++ b/vscode/rootfs/var/lib/code-server/defaults/core/TASK_HELPER.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# This file is a place to store exported functions for VS-Code tasks. + +# shellcheck source=./PATHS.sh +source "/etc/s6-overlay/s6-rc.d/paths.sh" + +show_vars() { + # echos all env vars to the log + bashio::log.info "ENV VARS:" + set -o posix ; set | while IFS='' read -r line + do + echo "$line" + done +} + +export -f show_vars diff --git a/vscode/rootfs/var/lib/code-server/defaults/core/custom-scripts.md b/vscode/rootfs/var/lib/code-server/defaults/core/custom-scripts.md index 326af24..bab2915 100644 --- a/vscode/rootfs/var/lib/code-server/defaults/core/custom-scripts.md +++ b/vscode/rootfs/var/lib/code-server/defaults/core/custom-scripts.md @@ -13,3 +13,5 @@ change ENABLE to true and restart the VS Code server instance. ## PATHS.sh This shows all paths used at boot time. USER_CUSTOM_DIR is for storage of build sources, etc. + +## TASK_HELPER.sh diff --git a/vscode/rootfs/var/lib/code-server/defaults/vscode/SERVER.code-workspace b/vscode/rootfs/var/lib/code-server/defaults/vscode/SERVER.code-workspace index 5709732..e668bb2 100644 --- a/vscode/rootfs/var/lib/code-server/defaults/vscode/SERVER.code-workspace +++ b/vscode/rootfs/var/lib/code-server/defaults/vscode/SERVER.code-workspace @@ -4,5 +4,11 @@ "path": "." } ], - "settings": {} + "settings": {}, + "extensions": { + "recommendations": [ + "aaaaronzhou.vscode-auto-light-dark-theme", + "pinage404.bash-extension-pack" + ] + } } diff --git a/vscode/rootfs/var/lib/code-server/defaults/vscode/tasks.json b/vscode/rootfs/var/lib/code-server/defaults/vscode/tasks.json index 3d35f44..c4e4550 100644 --- a/vscode/rootfs/var/lib/code-server/defaults/vscode/tasks.json +++ b/vscode/rootfs/var/lib/code-server/defaults/vscode/tasks.json @@ -1,9 +1,24 @@ { - "version": "2.0.0", - "tasks": [ - { + "version": "2.0.0", + "tasks": [ + { + "label": "Show ENV Vars", + "type": "shell", + "command": "show_vars", + "group": { + "kind": "helpers", + "isDefault": true + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [] + } + ] +} - } - ] - } - diff --git a/vscode/rootfs/var/lib/code-server/defaults/vscode/workspaces.json b/vscode/rootfs/var/lib/code-server/defaults/vscode/workspaces.json deleted file mode 100644 index 219b4fe..0000000 --- a/vscode/rootfs/var/lib/code-server/defaults/vscode/workspaces.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rootWorkspaces": [], - "folderURIWorkspaces": [], - "emptyWorkspaceInfos": [], - "emptyWorkspaces": [] -}