mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-16 18:23:27 +01:00
tools.func: persist /usr/local/bin in shell PATHs
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user