diff --git a/misc/alpine-tools.func b/misc/alpine-tools.func index d2efb8cdb..958c30680 100644 --- a/misc/alpine-tools.func +++ b/misc/alpine-tools.func @@ -34,11 +34,19 @@ net_resolves() { } ensure_usr_local_bin_persist() { + # Login shells: /etc/profile.d/ local PROFILE_FILE="/etc/profile.d/10-localbin.sh" if [ ! -f "$PROFILE_FILE" ]; then echo 'case ":$PATH:" in *:/usr/local/bin:*) ;; *) export PATH="/usr/local/bin:$PATH";; esac' >"$PROFILE_FILE" chmod +x "$PROFILE_FILE" fi + + # Non-login shells (pct enter): /root/.profile and /root/.bashrc + for rc_file in /root/.profile /root/.bashrc; do + if [ -f "$rc_file" ] && ! grep -q '/usr/local/bin' "$rc_file"; then + echo 'export PATH="/usr/local/bin:$PATH"' >>"$rc_file" + fi + done } download_with_progress() { diff --git a/misc/tools.func b/misc/tools.func index 166284c6c..d12cef3be 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1851,16 +1851,26 @@ function download_with_progress() { # Ensures /usr/local/bin is permanently in system PATH. # # Description: -# - Adds to /etc/profile.d if not present +# - Adds to /etc/profile.d for login shells (SSH, noVNC) +# - Adds to /root/.bashrc for non-login shells (pct enter) # ------------------------------------------------------------------------------ function ensure_usr_local_bin_persist() { - local PROFILE_FILE="/etc/profile.d/custom_path.sh" + # Skip on Proxmox host + command -v pveversion &>/dev/null && return - if [[ ! -f "$PROFILE_FILE" ]] && ! command -v pveversion &>/dev/null; then + # Login shells: /etc/profile.d/ + local PROFILE_FILE="/etc/profile.d/custom_path.sh" + if [[ ! -f "$PROFILE_FILE" ]]; then echo 'export PATH="/usr/local/bin:$PATH"' >"$PROFILE_FILE" chmod +x "$PROFILE_FILE" fi + + # Non-login shells (pct enter): /root/.bashrc + local BASHRC="/root/.bashrc" + if [[ -f "$BASHRC" ]] && ! grep -q '/usr/local/bin' "$BASHRC"; then + echo 'export PATH="/usr/local/bin:$PATH"' >>"$BASHRC" + fi } # ------------------------------------------------------------------------------