Skip to content

Commit 0c4d617

Browse files
authored
chore: add host_env script (#82)
1 parent ca87ef6 commit 0c4d617

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

docker/setup_host/host_env.sh

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
###############################################################################
4-
# Copyright 2018 The Apollo Authors. All Rights Reserved.
4+
# Copyright 2025 The WheelOS Team. All Rights Reserved.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -15,13 +15,31 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
###############################################################################
18-
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
1918

20-
PYTHON_USER_BASE=$(python3 -c 'import site; print(site.USER_BASE)')
21-
PYTHON_INSTALL_PATH="${PYTHON_USER_BASE}/apollo/tools"
22-
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))')
19+
LOCAL_BIN_PATH="$HOME/.local/bin"
20+
BASHRC="$HOME/.bashrc"
21+
MARKER="# [apollo-deploy] Added by host_env.sh"
2322

24-
source ${APOLLO_ROOT_DIR}/scripts/common.bashrc
23+
echo "Setup host environment..."
2524

26-
pathprepend "${PYTHON_INSTALL_PATH}/lib/python${PYTHON_VERSION}/site-packages" PYTHONPATH
27-
pathprepend "${PYTHON_INSTALL_PATH}/bin/" PATH
25+
mkdir -p "$LOCAL_BIN_PATH"
26+
27+
if ! grep -qF "$MARKER" "$BASHRC"; then
28+
echo "Writing PATH update snippet to $BASHRC..."
29+
cat << EOF >> "$BASHRC"
30+
$MARKER
31+
if [ -d "\$HOME/.local/bin" ] && [[ ":\$PATH:" != *":\$HOME/.local/bin:"* ]]; then
32+
export PATH="\$HOME/.local/bin:\$PATH"
33+
fi
34+
EOF
35+
else
36+
echo "Environment variables already configured in $BASHRC."
37+
fi
38+
39+
# Apply immediately to the current shell
40+
if [ -d "$LOCAL_BIN_PATH" ] && [[ ":$PATH:" != *":$LOCAL_BIN_PATH:"* ]]; then
41+
export PATH="$LOCAL_BIN_PATH:$PATH"
42+
echo "Updated PATH for current shell."
43+
fi
44+
45+
echo "Current PATH: $PATH"

0 commit comments

Comments
 (0)