-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathstart.sh
More file actions
54 lines (45 loc) · 1.57 KB
/
start.sh
File metadata and controls
54 lines (45 loc) · 1.57 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
#!/usr/bin/env bash
# MasterHttpRelayVPN one-click launcher (Linux / macOS)
# Creates a local virtualenv, installs deps, runs the setup wizard
# if needed, then starts the proxy.
set -e
cd "$(dirname "$0")"
VENV_DIR=".venv"
find_python() {
for cmd in python3.12 python3.11 python3.10 python3 python; do
if command -v "$cmd" >/dev/null 2>&1; then
ver=$("$cmd" -c 'import sys;print("%d.%d"%sys.version_info[:2])' 2>/dev/null || echo "0.0")
major=${ver%.*}; minor=${ver#*.}
if [ "$major" -ge 3 ] && [ "$minor" -ge 10 ]; then
echo "$cmd"
return 0
fi
fi
done
return 1
}
PY=$(find_python) || {
echo "[X] Python 3.10+ not found. Install it and re-run this script." >&2
exit 1
}
if [ ! -x "$VENV_DIR/bin/python" ]; then
echo "[*] Creating virtual environment in $VENV_DIR ..."
"$PY" -m venv "$VENV_DIR"
fi
VPY="$VENV_DIR/bin/python"
echo "[*] Installing dependencies ..."
"$VPY" -m pip install --disable-pip-version-check -q --upgrade pip >/dev/null
if ! "$VPY" -m pip install --disable-pip-version-check -q -r requirements.txt; then
echo "[!] PyPI install failed. Retrying via runflare mirror ..."
"$VPY" -m pip install --disable-pip-version-check -q -r requirements.txt \
-i https://mirror-pypi.runflare.com/simple/ \
--trusted-host mirror-pypi.runflare.com
fi
if [ ! -f "config.json" ]; then
echo "[*] No config.json found — launching setup wizard ..."
"$VPY" setup.py
fi
echo
echo "[*] Starting MasterHttpRelayVPN ..."
echo
exec "$VPY" main.py "$@"