-
Notifications
You must be signed in to change notification settings - Fork 819
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·69 lines (58 loc) · 1.9 KB
/
setup.sh
File metadata and controls
executable file
·69 lines (58 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Load environment variables from .env file if it exists
if [ -f .env ]; then
# Read .env file line by line, ignoring comments and empty lines
while IFS= read -r line || [ -n "$line" ]; do
# Skip comments and empty lines
[[ $line =~ ^#.*$ ]] && continue
[[ -z $line ]] && continue
# Export the variable
export "$line"
done < .env
fi
if ! command -v sudo >/dev/null 2>&1; then
sudo_path="/usr/local/bin/sudo"
if [ ! -w /usr/local/bin ]; then
sudo_path="$HOME/.local/bin/sudo"
mkdir -p "$HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
fi
cat <<'EOF' > "$sudo_path"
#!/bin/sh
exec "$@"
EOF
chmod +x "$sudo_path"
fi
need_pkgs=()
command -v git >/dev/null 2>&1 || need_pkgs+=("git")
command -v curl >/dev/null 2>&1 || need_pkgs+=("curl")
command -v tmux >/dev/null 2>&1 || need_pkgs+=("tmux")
if [ "${#need_pkgs[@]}" -gt 0 ]; then
apt-get update
apt-get install -y "${need_pkgs[@]}"
fi
# Configure git user name and email
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
git config --global --add safe.directory /root/sky_workdir
if [ "${GIT_RESET_CLEAN:-true}" = "true" ]; then
# Reset any uncommitted changes to the last commit
git reset --hard HEAD
# Remove all untracked files and directories
git clean -fd
else
echo "Skipping git reset/clean (GIT_RESET_CLEAN is not true). Preserving synced working tree."
fi
# Install astral-uv (standalone version)
# Always prepend standalone install path so it takes precedence over system/conda uv
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
if ! curl -LsSf https://astral.sh/uv/install.sh | sh; then
echo "Failed to install uv." >&2
exit 1
fi
# Sync the dependencies
if [ "${INSTALL_EXTRAS:-false}" = "true" ]; then
uv sync --all-extras
else
uv sync --extra backend
fi