Skip to content

Commit

Permalink
user-init: Safeguarded linking directories via the --no-dereference f…
Browse files Browse the repository at this point in the history
…lag to avoid link-loops. Catching linking of .gitignore and .ssh via a warning, so that s6 does does not crash (and with it, the container)
  • Loading branch information
systemofapwne committed Feb 3, 2025
1 parent 3faac46 commit 70ade45
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vscode/rootfs/etc/s6-overlay/s6-rc.d/init-user/run
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ readonly ZSH_HISTORY_PERSISTANT_FILE=/data/.zsh_history

# Links some common directories to the user's home folder for convenience
for dir in "${DIRECTORIES[@]}"; do
ln -s "/${dir}" "${HOME}/${dir}" \
ln -sn "/${dir}" "${HOME}/${dir}" \
|| bashio::log.warning "Failed linking common directory: ${dir}"
done

# Some links to old locations, to not mess with the user's muscle memory
ln -s "/config" "${HOME}/config" \
ln -sn "/config" "${HOME}/config" \
|| bashio::log.warning "Failed linking common directory: ${HOME}/config"
ln -s "/config" "/homeassistant" \
ln -sn "/config" "/homeassistant" \
|| bashio::log.warning "Failed linking common directory: /homeassistant"

# Store SSH settings in add-on data folder
Expand All @@ -31,7 +31,7 @@ if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
|| bashio::exit.nok \
'Failed setting permissions on persistent .ssh folder'
fi
ln -s "${SSH_USER_PATH}" ~/.ssh
ln -sn "${SSH_USER_PATH}" ~/.ssh || bashio::log.warning "Failed linking .ssh"

# Sets up ZSH shell
touch "${ZSH_HISTORY_PERSISTANT_FILE}" \
Expand All @@ -58,7 +58,7 @@ if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
touch "${GIT_USER_PATH}/.gitconfig" \
|| bashio::exit.nok 'Failed to create .gitconfig'
fi
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig || bashio::log.warning "Failed linking .gitconfig"

# Install user configured/requested packages
if bashio::config.has_value 'packages'; then
Expand Down

0 comments on commit 70ade45

Please # to comment.