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 full-upgrade -y \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
ack \
|
ack \
|
||||||
|
direnv \
|
||||||
libarchive-tools \
|
libarchive-tools \
|
||||||
colordiff \
|
colordiff \
|
||||||
git \
|
git \
|
||||||
|
|
|
@ -4,36 +4,27 @@
|
||||||
# Home Assistant Community Add-on: Studio Code Server
|
# Home Assistant Community Add-on: Studio Code Server
|
||||||
# Sets up 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"
|
pathsfile="/etc/s6-overlay/s6-rc.d/paths.sh"
|
||||||
# shellcheck source=../paths.sh
|
# shellcheck source=../paths.sh
|
||||||
source "${pathsfile}"
|
source "${pathsfile}"
|
||||||
|
|
||||||
# List of previous config hashes, to allow upgrade "default" configs.
|
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
if [ ! -d "$CUSTOM_BASH_SCRIPTS_PATH" ]; then
|
setup
|
||||||
bashio::log.warning "CUSTOM_BASH_SCRIPTS_PATH path does not exist. Creating..."
|
run_boot_scripts
|
||||||
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
|
core_file_copy() {
|
||||||
bashio::log.warning "custom-scripts.md does not exist."
|
local fname=${1}
|
||||||
cp "$DEFAULT_FILES_PATH"/core/custom-scripts.md "$CUSTOM_BASH_SCRIPTS_PATH"/custom-scripts.md
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/example-mqtt.sh ]]; then
|
if [[ ! -e "$CUSTOM_BASH_SCRIPTS_PATH"/"$fname" ]]; then
|
||||||
bashio::log.warning "example-mqtt.sh does not exist."
|
bashio::log.warning "$fname does not exist."
|
||||||
cp "$DEFAULT_FILES_PATH"/core/example-mqtt.sh "$CUSTOM_BASH_SCRIPTS_PATH"/example-mqtt.sh
|
cp "$DEFAULT_FILES_PATH"/core/"$fname" "$CUSTOM_BASH_SCRIPTS_PATH"/"$fname"
|
||||||
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
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_boot_scripts() {
|
||||||
if [ "$(ls -A "$CUSTOM_BASH_SCRIPTS_PATH")" ]; then
|
if [ "$(ls -A "$CUSTOM_BASH_SCRIPTS_PATH")" ]; then
|
||||||
for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do
|
for script in "${CUSTOM_BASH_SCRIPTS_PATH}"/*.sh; do
|
||||||
if [ "$script" = "$pathsfile" ]; then
|
if [ "$script" = "$pathsfile" ]; then
|
||||||
|
@ -46,4 +37,24 @@ run() {
|
||||||
fi
|
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
|
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
|
## PATHS.sh
|
||||||
|
|
||||||
This shows all paths used at boot time. USER_CUSTOM_DIR is for storage of build sources, etc.
|
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": "."
|
"path": "."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {}
|
"settings": {},
|
||||||
|
"extensions": {
|
||||||
|
"recommendations": [
|
||||||
|
"aaaaronzhou.vscode-auto-light-dark-theme",
|
||||||
|
"pinage404.bash-extension-pack"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"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