From 3d604d48091233ac8c1bb1deac7d15e20817e06c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 11 Jan 2026 08:49:57 +0100 Subject: [PATCH] Ensure HOME directory exists before export --- .templates/00-global_var.sh | 9 ++++++--- .templates/01-config_yaml.sh | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.templates/00-global_var.sh b/.templates/00-global_var.sh index c2b2f9221..683110edb 100755 --- a/.templates/00-global_var.sh +++ b/.templates/00-global_var.sh @@ -301,11 +301,14 @@ done update_scripts_with_block # --- MINIMAL CHANGE: also inject into /etc/bash.bashrc (for interactive bash shells) -mkdir -p /etc "$HOME" +mkdir -p /etc touch "/etc/bash.bashrc" -touch "$HOME/bash.bashrc" inject_block_into_file "/etc/bash.bashrc" -inject_block_into_file "$HOME/bash.bashrc" +if [[ -n "${HOME:-}" ]]; then + mkdir -p "$HOME" + touch "$HOME/bash.bashrc" + inject_block_into_file "$HOME/bash.bashrc" +fi ################ # Set timezone # diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index 245bb9222..d36a9287d 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -205,7 +205,10 @@ while IFS= read -r line; do if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi # Persist for interactive shells - append_unique_line "$HOME/.bashrc" "export $line" + if [[ -n "${HOME:-}" ]]; then + mkdir -p "$HOME" + append_unique_line "$HOME/.bashrc" "export $line" + fi append_unique_line "/etc/bash.bashrc" "export $line" # Show in log