79 lines
1.9 KiB
Bash
Executable File
79 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
INSTALL_DIR="${VPN_PROXY_INSTALL_DIR:-$HOME/.vpn-proxy-client}"
|
|
REPO_URL="${VPN_PROXY_REPO_URL:-https://git.dokops.ru/dokril/vpn-proxy.git}"
|
|
BRANCH="${VPN_PROXY_BRANCH:-master}"
|
|
COMPOSE_FILE="docker-compose.client.yml"
|
|
|
|
log() {
|
|
printf '[vpn-proxy-client] %s\n' "$*"
|
|
}
|
|
|
|
die() {
|
|
printf '[vpn-proxy-client] error: %s\n' "$*" >&2
|
|
exit 1
|
|
}
|
|
|
|
need() {
|
|
command -v "$1" >/dev/null 2>&1 || die "$1 is required"
|
|
}
|
|
|
|
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
die "this installer is intended for macOS"
|
|
fi
|
|
|
|
need git
|
|
need docker
|
|
|
|
docker compose version >/dev/null 2>&1 || die "Docker Compose plugin is required"
|
|
docker info >/dev/null 2>&1 || die "Docker Desktop is not running"
|
|
|
|
if [[ -d "$INSTALL_DIR/.git" ]]; then
|
|
log "updating $INSTALL_DIR"
|
|
git -C "$INSTALL_DIR" fetch origin "$BRANCH"
|
|
git -C "$INSTALL_DIR" checkout "$BRANCH"
|
|
git -C "$INSTALL_DIR" pull --ff-only origin "$BRANCH"
|
|
else
|
|
log "cloning $REPO_URL#$BRANCH to $INSTALL_DIR"
|
|
mkdir -p "$(dirname "$INSTALL_DIR")"
|
|
git clone --branch "$BRANCH" "$REPO_URL" "$INSTALL_DIR"
|
|
fi
|
|
|
|
cd "$INSTALL_DIR"
|
|
|
|
if [[ ! -f .env && -f .env.example ]]; then
|
|
cp .env.example .env
|
|
fi
|
|
|
|
log "building and starting Docker client"
|
|
docker compose -f "$COMPOSE_FILE" up -d --build
|
|
|
|
cat <<'EOF'
|
|
|
|
VPN Proxy Client is running.
|
|
|
|
UI:
|
|
http://127.0.0.1:3456
|
|
|
|
Proxy:
|
|
HTTP/SOCKS5 127.0.0.1:8080
|
|
|
|
Useful commands:
|
|
cd ~/.vpn-proxy-client
|
|
docker compose -f docker-compose.client.yml logs -f
|
|
docker compose -f docker-compose.client.yml restart
|
|
docker compose -f docker-compose.client.yml down
|
|
|
|
Optional macOS system proxy example:
|
|
networksetup -setwebproxy Wi-Fi 127.0.0.1 8080
|
|
networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 8080
|
|
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 8080
|
|
|
|
Disable later:
|
|
networksetup -setwebproxystate Wi-Fi off
|
|
networksetup -setsecurewebproxystate Wi-Fi off
|
|
networksetup -setsocksfirewallproxystate Wi-Fi off
|
|
|
|
EOF
|