Files
vpndock/deploy.sh
Malin 505da89144 feat: initial vpndock stack
HAProxy SOCKS5 entry point + scalable purevpn-cli/microsocks exit nodes.
Supports up to 10 simultaneous connections (PureVPN limit), random location
selection from a predefined pool, and automatic reconnect to an unused
location on server-side drop.
2026-03-11 09:45:42 +01:00

63 lines
2.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# deploy.sh Build and scale the vpndock stack
#
# Usage:
# ./deploy.sh → deploy 3 VPN exit nodes (default)
# ./deploy.sh 5 → deploy 5 VPN exit nodes
# ./deploy.sh 10 → deploy 10 VPN exit nodes (PureVPN's max simultaneous connections)
# ./deploy.sh 0 → tear down the stack
#
set -euo pipefail
SCALE=${1:-3}
MAX_CONNECTIONS=10
COMPOSE="docker compose"
# ── Sanity checks ─────────────────────────────────────────────────────────────
if [[ ! -f .env ]]; then
echo "ERROR: .env file not found. Copy .env.example and fill in your credentials:"
echo " cp .env.example .env && nano .env"
exit 1
fi
if [[ "$SCALE" -gt "$MAX_CONNECTIONS" ]]; then
echo "WARNING: PureVPN allows max $MAX_CONNECTIONS simultaneous connections."
echo " Capping scale at $MAX_CONNECTIONS."
SCALE=$MAX_CONNECTIONS
fi
# ── Tear down ─────────────────────────────────────────────────────────────────
if [[ "$SCALE" -eq 0 ]]; then
echo "Tearing down vpndock stack …"
$COMPOSE down
exit 0
fi
# ── Build & deploy ────────────────────────────────────────────────────────────
echo "──────────────────────────────────────────────"
echo " vpndock deploy"
echo " VPN exit nodes : $SCALE"
echo " SOCKS5 port : ${SOCKS5_PORT:-1080} (on host)"
echo " Stats UI : http://localhost:8404/stats"
echo "──────────────────────────────────────────────"
echo ""
echo "Building images …"
$COMPOSE build
echo ""
echo "Starting stack with $SCALE VPN exit node(s) …"
$COMPOSE up -d --scale vpn-node="$SCALE"
echo ""
echo "Stack is up. Waiting for containers to stabilise …"
sleep 5
$COMPOSE ps
echo ""
echo "Done! Configure your browser's SOCKS5 proxy:"
echo " Host : $(hostname -I | awk '{print $1}')"
echo " Port : ${SOCKS5_PORT:-1080}"
echo ""
echo "HAProxy stats: http://localhost:8404/stats (admin / admin)"