mirror of
https://github.com/hassio-addons/addon-vscode.git
synced 2025-05-03 18:51:23 +00:00
devenv
This commit is contained in:
parent
8482489498
commit
1d7e8a31e4
7 changed files with 80 additions and 35 deletions
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -4,5 +4,11 @@
|
|||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
"settings": {},
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"aaaaronzhou.vscode-auto-light-dark-theme",
|
||||
"pinage404.bash-extension-pack"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"rootWorkspaces": [],
|
||||
"folderURIWorkspaces": [],
|
||||
"emptyWorkspaceInfos": [],
|
||||
"emptyWorkspaces": []
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue