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
29a56f36d8
commit
7cb8d61844
5 changed files with 90 additions and 50 deletions
|
@ -97,6 +97,21 @@ setup_code_workspace() {
|
||||||
bashio::log.warning "CODE_SERVER_VSCODE_TASKS does not exist. Creating..."
|
bashio::log.warning "CODE_SERVER_VSCODE_TASKS does not exist. Creating..."
|
||||||
cp "$DEFAULT_FILES_PATH/vscode/tasks.json" "$CODE_SERVER_VSCODE_TASKS"
|
cp "$DEFAULT_FILES_PATH/vscode/tasks.json" "$CODE_SERVER_VSCODE_TASKS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# custom tasks paths file
|
||||||
|
CUSTOM_BASH_SCRIPTS_PATH_SYMLINK="$CUSTOM_BASH_SCRIPTS_PATH/PATHS.sh"
|
||||||
|
if [ ! -e "$CUSTOM_BASH_SCRIPTS_PATH_SYMLINK" ]; then
|
||||||
|
bashio::log.warning "CUSTOM_BASH_SCRIPTS_PATH_ does not exist. Creating..."
|
||||||
|
ln -sn "/etc/s6-overlay/s6-rc.d/paths.sh" "$CUSTOM_BASH_SCRIPTS_PATH_SYMLINK" ||
|
||||||
|
bashio::log.warning "Failed linking PATHS.sh"
|
||||||
|
elif [ ! -L "$CUSTOM_BASH_SCRIPTS_PATH_SYMLINK" ]; then
|
||||||
|
bashio::log.warning "Failed path.sh link: Removing and recreating..."
|
||||||
|
rm -f"$CUSTOM_BASH_SCRIPTS_PATH_SYMLINK"
|
||||||
|
ln -sn "/etc/s6-overlay/s6-rc.d/paths.sh" "$CUSTOM_BASH_SCRIPTS_PATH_SYMLINK" ||
|
||||||
|
bashio::log.warning "Failed linking PATHS.sh"
|
||||||
|
else
|
||||||
|
bashio::log.info "Custom scripts symlink has a good link..."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_config_path() {
|
setup_config_path() {
|
||||||
|
@ -201,7 +216,6 @@ setup_user_settings() {
|
||||||
if ! bashio::fs.file_exists "$user_path"/workspaces.json; then
|
if ! bashio::fs.file_exists "$user_path"/workspaces.json; then
|
||||||
cp "$DEFAULT_FILES_PATH/vscode/workspaces.json" "$user_path/workspaces.json"
|
cp "$DEFAULT_FILES_PATH/vscode/workspaces.json" "$user_path/workspaces.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run
|
run
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
# Sets up code-server.
|
# Sets up code-server.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
bashio::log.info "Initalizing code-server configs"
|
bashio::log.info "Initalizing code-server configs"
|
||||||
|
pathsfile="/etc/s6-overlay/s6-rc.d/paths.sh"
|
||||||
# shellcheck source=../paths.sh
|
# shellcheck source=../paths.sh
|
||||||
source "/etc/s6-overlay/s6-rc.d/paths.sh"
|
source "${pathsfile}"
|
||||||
|
|
||||||
# List of previous config hashes, to allow upgrade "default" configs.
|
# List of previous config hashes, to allow upgrade "default" configs.
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ run() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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/!"$pathsfile"; do
|
||||||
|
|
||||||
echo "Running custom script: $script"
|
echo "Running custom script: $script"
|
||||||
chmod +x "$script"
|
chmod +x "$script"
|
||||||
"$script"
|
"$script"
|
||||||
|
|
|
@ -9,59 +9,77 @@ readonly SSH_USER_PATH=/data/.ssh
|
||||||
readonly ZSH_HISTORY_FILE=/root/.zsh_history
|
readonly ZSH_HISTORY_FILE=/root/.zsh_history
|
||||||
readonly ZSH_HISTORY_PERSISTANT_FILE=/data/.zsh_history
|
readonly ZSH_HISTORY_PERSISTANT_FILE=/data/.zsh_history
|
||||||
|
|
||||||
# Store SSH settings in add-on data folder
|
run() {
|
||||||
if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
|
setup_ssh
|
||||||
mkdir -p "${SSH_USER_PATH}" ||
|
setup_zsh
|
||||||
bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
setup_git
|
||||||
|
setup_config_packages
|
||||||
|
exec_config_cmds
|
||||||
|
}
|
||||||
|
|
||||||
chmod 700 "${SSH_USER_PATH}" ||
|
setup_ssh() {
|
||||||
bashio::exit.nok \
|
# Store SSH settings in add-on data folder
|
||||||
'Failed setting permissions on persistent .ssh folder'
|
if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
|
||||||
fi
|
mkdir -p "${SSH_USER_PATH}" ||
|
||||||
ln -sn "${SSH_USER_PATH}" ~/.ssh || bashio::log.warning "Failed linking .ssh"
|
bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
||||||
|
|
||||||
# Sets up ZSH shell
|
chmod 700 "${SSH_USER_PATH}" ||
|
||||||
touch "${ZSH_HISTORY_PERSISTANT_FILE}" ||
|
bashio::exit.nok \
|
||||||
bashio::exit.nok 'Failed creating a persistent ZSH history file'
|
'Failed setting permissions on persistent .ssh folder'
|
||||||
|
fi
|
||||||
|
ln -sn "${SSH_USER_PATH}" ~/.ssh || bashio::log.warning "Failed linking .ssh"
|
||||||
|
}
|
||||||
|
|
||||||
chmod 600 "$ZSH_HISTORY_PERSISTANT_FILE" ||
|
setup_zsh() {
|
||||||
bashio::exit.nok \
|
# Sets up ZSH shell
|
||||||
'Failed setting the correct permissions to the ZSH history file'
|
touch "${ZSH_HISTORY_PERSISTANT_FILE}" ||
|
||||||
|
bashio::exit.nok 'Failed creating a persistent ZSH history file'
|
||||||
|
|
||||||
ln -s -f "$ZSH_HISTORY_PERSISTANT_FILE" "$ZSH_HISTORY_FILE" ||
|
chmod 600 "$ZSH_HISTORY_PERSISTANT_FILE" ||
|
||||||
bashio::exit.nok 'Failed linking the persistant ZSH history file'
|
bashio::exit.nok 'Failed setting the correct permissions to the ZSH history file'
|
||||||
|
|
||||||
# Store user GIT settings in add-on data folder
|
ln -s -f "$ZSH_HISTORY_PERSISTANT_FILE" "$ZSH_HISTORY_FILE" ||
|
||||||
if ! bashio::fs.directory_exists "${GIT_USER_PATH}"; then
|
bashio::exit.nok 'Failed linking the persistant ZSH history file'
|
||||||
mkdir -p "${GIT_USER_PATH}" ||
|
}
|
||||||
bashio::exit.nok 'Failed to create a persistent git folder'
|
|
||||||
|
|
||||||
chmod 700 "${GIT_USER_PATH}" ||
|
setup_git() {
|
||||||
bashio::exit.nok \
|
# Store user GIT settings in add-on data folder
|
||||||
'Failed setting permissions on persistent git folder'
|
if ! bashio::fs.directory_exists "${GIT_USER_PATH}"; then
|
||||||
fi
|
mkdir -p "${GIT_USER_PATH}" ||
|
||||||
|
bashio::exit.nok 'Failed to create a persistent git folder'
|
||||||
|
|
||||||
if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
|
chmod 700 "${GIT_USER_PATH}" ||
|
||||||
touch "${GIT_USER_PATH}/.gitconfig" ||
|
bashio::exit.nok 'Failed setting permissions on persistent git folder'
|
||||||
bashio::exit.nok 'Failed to create .gitconfig'
|
fi
|
||||||
fi
|
|
||||||
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig || bashio::log.warning "Failed linking .gitconfig"
|
|
||||||
|
|
||||||
# Install user configured/requested packages
|
if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
|
||||||
if bashio::config.has_value 'packages'; then
|
touch "${GIT_USER_PATH}/.gitconfig" ||
|
||||||
apt update ||
|
bashio::exit.nok 'Failed to create .gitconfig'
|
||||||
bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
|
fi
|
||||||
|
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig || bashio::log.warning "Failed linking .gitconfig"
|
||||||
|
}
|
||||||
|
|
||||||
for package in $(bashio::config 'packages'); do
|
setup_config_packages() {
|
||||||
apt-get install -y "$package" ||
|
# Install user configured/requested packages
|
||||||
bashio::exit.nok "Failed installing package ${package}"
|
if bashio::config.has_value 'packages'; then
|
||||||
done
|
apt update ||
|
||||||
fi
|
bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
|
||||||
|
|
||||||
# Executes user configured/requested commands on startup
|
for package in $(bashio::config 'packages'); do
|
||||||
if bashio::config.has_value 'init_commands'; then
|
apt-get install -y "$package" ||
|
||||||
while read -r cmd; do
|
bashio::exit.nok "Failed installing package ${package}"
|
||||||
eval "${cmd}" ||
|
done
|
||||||
bashio::exit.nok "Failed executing init command: ${cmd}"
|
fi
|
||||||
done <<<"$(bashio::config 'init_commands')"
|
}
|
||||||
fi
|
|
||||||
|
exec_config_cmds() {
|
||||||
|
# Executes user configured/requested commands on startup
|
||||||
|
if bashio::config.has_value 'init_commands'; then
|
||||||
|
while read -r cmd; do
|
||||||
|
eval "${cmd}" ||
|
||||||
|
bashio::exit.nok "Failed executing init command: ${cmd}"
|
||||||
|
done <<<"$(bashio::config 'init_commands')"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run
|
||||||
|
|
|
@ -14,3 +14,8 @@ readonly CODE_SERVER_VSCODE_TASKS="$CODE_SERVER_VSCODE_DIR/tasks.json"
|
||||||
|
|
||||||
readonly CUSTOM_BASH_SCRIPTS_PATH="/data/vscode/custom_boot_scripts"
|
readonly CUSTOM_BASH_SCRIPTS_PATH="/data/vscode/custom_boot_scripts"
|
||||||
readonly -a DIRECTORIES=(backup config media share ssl)
|
readonly -a DIRECTORIES=(backup config media share ssl)
|
||||||
|
|
||||||
|
readonly GIT_USER_PATH=/data/git
|
||||||
|
readonly SSH_USER_PATH=/data/.ssh
|
||||||
|
readonly ZSH_HISTORY_FILE=/root/.zsh_history
|
||||||
|
readonly ZSH_HISTORY_PERSISTANT_FILE=/data/.zsh_history
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
ENABLE=false
|
ENABLE=false
|
||||||
|
# shellcheck source=../paths.sh
|
||||||
|
source "/etc/s6-overlay/s6-rc.d/paths.sh"
|
||||||
|
|
||||||
if [ "$ENABLE" = true ]; then
|
if [ "$ENABLE" = true ]; then
|
||||||
echo "Custom Script"
|
echo "Custom Script"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue