Skip to content

Commit 42a341a

Browse files
authored
add profile function and export PATH to prevent issues in future (#4133)
1 parent e09b216 commit 42a341a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

misc/tools.func

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,7 @@ import_local_ip() {
758758
}
759759

760760
function setup_uv() {
761-
msg_info "Checking uv installation..."
762-
761+
$STD msg_info "Checking uv installation..."
763762
UV_BIN="/usr/local/bin/uv"
764763
TMP_DIR=$(mktemp -d)
765764
ARCH=$(uname -m)
@@ -786,18 +785,18 @@ function setup_uv() {
786785
if [[ -x "$UV_BIN" ]]; then
787786
INSTALLED_VERSION=$($UV_BIN -V | awk '{print $2}')
788787
if [[ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]]; then
789-
msg_ok "uv is already at the latest version ($INSTALLED_VERSION)"
788+
$STD msg_ok "uv is already at the latest version ($INSTALLED_VERSION)"
790789
rm -rf "$TMP_DIR"
791790
# set path
792791
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
793792
export PATH="/usr/local/bin:$PATH"
794793
fi
795794
return 0
796795
else
797-
msg_info "Updating uv from $INSTALLED_VERSION to $LATEST_VERSION"
796+
$STD msg_info "Updating uv from $INSTALLED_VERSION to $LATEST_VERSION"
798797
fi
799798
else
800-
msg_info "uv not found. Installing version $LATEST_VERSION"
799+
$STD msg_info "uv not found. Installing version $LATEST_VERSION"
801800
fi
802801

803802
# install or update uv
@@ -807,9 +806,15 @@ function setup_uv() {
807806
rm -rf "$TMP_DIR"
808807

809808
# set path
810-
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
811-
export PATH="/usr/local/bin:$PATH"
812-
fi
813-
809+
ensure_usr_local_bin_persist
814810
msg_ok "uv installed/updated to $LATEST_VERSION"
815811
}
812+
813+
function ensure_usr_local_bin_persist() {
814+
local PROFILE_FILE="/etc/profile.d/custom_path.sh"
815+
816+
if [[ ! -f "$PROFILE_FILE" ]] && ! command -v pveversion &>/dev/null; then
817+
echo 'export PATH="/usr/local/bin:$PATH"' >"$PROFILE_FILE"
818+
chmod +x "$PROFILE_FILE"
819+
fi
820+
}

0 commit comments

Comments
 (0)