mirror of
https://github.com/masterking32/MasterHttpRelayVPN.git
synced 2026-05-17 21:24:37 +03:00
fix: streamline vps_exit_node.sh to directly download vps_exit_node.py from GitHub
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#
|
#
|
||||||
# What this script does:
|
# What this script does:
|
||||||
# 1. Verifies the OS is Linux (aborts otherwise)
|
# 1. Verifies the OS is Linux (aborts otherwise)
|
||||||
# 2. Fetches vps_exit_node.py from GitHub if not present locally
|
# 2. Downloads vps_exit_node.py from GitHub
|
||||||
# 3. Installs Python 3 if not present
|
# 3. Installs Python 3 if not present
|
||||||
# 4. Creates /opt/exit-node/ and copies vps_exit_node.py there
|
# 4. Creates /opt/exit-node/ and copies vps_exit_node.py there
|
||||||
# 5. Prompts for a PSK (or generates one automatically)
|
# 5. Prompts for a PSK (or generates one automatically)
|
||||||
@@ -54,15 +54,9 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Locate or download vps_exit_node.py ──────────────────────────────────────
|
# ── Download vps_exit_node.py from GitHub ────────────────────────────────────
|
||||||
# When piped from curl/wget, BASH_SOURCE[0] is /dev/stdin or empty,
|
|
||||||
# so we always check a fixed temp path first, then fall back to GitHub.
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-/dev/stdin}")" 2>/dev/null && pwd || echo "/tmp")"
|
|
||||||
PYTHON_SCRIPT="$SCRIPT_DIR/vps_exit_node.py"
|
|
||||||
|
|
||||||
if [[ ! -f "$PYTHON_SCRIPT" ]]; then
|
|
||||||
info "vps_exit_node.py not found locally — fetching from GitHub..."
|
|
||||||
PYTHON_SCRIPT="/tmp/vps_exit_node.py"
|
PYTHON_SCRIPT="/tmp/vps_exit_node.py"
|
||||||
|
info "Fetching vps_exit_node.py from GitHub..."
|
||||||
if command -v curl &>/dev/null; then
|
if command -v curl &>/dev/null; then
|
||||||
curl -fsSL "$GITHUB_RAW/vps_exit_node.py" -o "$PYTHON_SCRIPT"
|
curl -fsSL "$GITHUB_RAW/vps_exit_node.py" -o "$PYTHON_SCRIPT"
|
||||||
elif command -v wget &>/dev/null; then
|
elif command -v wget &>/dev/null; then
|
||||||
@@ -72,7 +66,6 @@ if [[ ! -f "$PYTHON_SCRIPT" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
info "Downloaded vps_exit_node.py to $PYTHON_SCRIPT"
|
info "Downloaded vps_exit_node.py to $PYTHON_SCRIPT"
|
||||||
fi
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
header "Step 1/7 — Checking Python 3"
|
header "Step 1/7 — Checking Python 3"
|
||||||
@@ -84,7 +77,7 @@ for candidate in python3 python3.12 python3.11 python3.10; do
|
|||||||
VER=$("$candidate" -c 'import sys; print("%d%d" % sys.version_info[:2])')
|
VER=$("$candidate" -c 'import sys; print("%d%d" % sys.version_info[:2])')
|
||||||
if [[ "$VER" -ge 310 ]]; then
|
if [[ "$VER" -ge 310 ]]; then
|
||||||
PYTHON_BIN=$(command -v "$candidate")
|
PYTHON_BIN=$(command -v "$candidate")
|
||||||
info "Found $PYTHON_BIN ($(\"$PYTHON_BIN\" --version 2>&1))"
|
info "Found $PYTHON_BIN ($($PYTHON_BIN --version 2>&1))"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -114,7 +107,8 @@ header "Step 2/7 — Collecting configuration"
|
|||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
# Port
|
# Port
|
||||||
read -rp $'\n'"Listen port [default: 8181]: " INPUT_PORT
|
echo ""
|
||||||
|
read -rp "Listen port [default: 8181]: " INPUT_PORT </dev/tty || INPUT_PORT=""
|
||||||
PORT="${INPUT_PORT:-8181}"
|
PORT="${INPUT_PORT:-8181}"
|
||||||
if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [[ "$PORT" -lt 1 ]] || [[ "$PORT" -gt 65535 ]]; then
|
if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [[ "$PORT" -lt 1 ]] || [[ "$PORT" -gt 65535 ]]; then
|
||||||
error "Invalid port: $PORT"
|
error "Invalid port: $PORT"
|
||||||
@@ -124,7 +118,7 @@ info "Port: $PORT"
|
|||||||
|
|
||||||
# PSK
|
# PSK
|
||||||
echo ""
|
echo ""
|
||||||
read -rp "Pre-shared key (leave empty to auto-generate): " INPUT_PSK
|
read -rp "Pre-shared key (leave empty to auto-generate): " INPUT_PSK </dev/tty || INPUT_PSK=""
|
||||||
if [[ -z "$INPUT_PSK" ]]; then
|
if [[ -z "$INPUT_PSK" ]]; then
|
||||||
PSK=$("$PYTHON_BIN" -c "import secrets; print(secrets.token_hex(32))")
|
PSK=$("$PYTHON_BIN" -c "import secrets; print(secrets.token_hex(32))")
|
||||||
info "Auto-generated PSK: ${BOLD}${PSK}${NC}"
|
info "Auto-generated PSK: ${BOLD}${PSK}${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user