GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opentunnel/install.sh at main · datamaker/opentunnel Expand file tree/ Copy pathinstall.shMore file actions executable file ·280 lines (244 loc) · 8.59 KB / Copy pathinstall.shFile metadata and controlsexecutable file ·280 lines (244 loc) · 8.59 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 #!/bin/bash # # OpenTunnel VPN - One-line installer # Usage: curl -fsSL https://raw.githubusercontent.com/datamaker/opentunnel/main/install.sh | sudo bash # set -e INSTALL_DIR="${INSTALL_DIR:-/opt/opentunnel}" DOCKER_IMAGE="datamaker/opentunnel:rust" VPN_SUBNET="10.8.0.0" echo " ____ _____ _ / __ \ |_ _| | | | | | |_ __ ___ _ __ | |_ _ _ __ _ __ ___| | | | | | '_ \ / _ \ '_ \ | | | | | '_ \| '_ \ / _ \ | | |__| | |_) | __/ | | | | | |_| | | | | | | | __/ | \____/| .__/ \___|_| |_| \_/\__,_|_| |_|_| |_|\___|_| | | |_| " echo "OpenTunnel VPN Installer v1.0" echo "=============================" echo "" # Check requirements command -v docker >/dev/null 2>&1 || { echo "Error: Docker is required but not installed."; exit 1; } # Check if running as root for system setup if [ "$EUID" -ne 0 ]; then echo "Error: This script must be run as root (use sudo)" exit 1 fi echo "Install directory: $INSTALL_DIR" echo "" # Create install directory mkdir -p "$INSTALL_DIR" cd "$INSTALL_DIR" # Generate random passwords DB_PASSWORD=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 24) JWT_SECRET=$(openssl rand -base64 32) # Fetch the DB schema (the Rust server does not auto-create it) curl -fsSL https://raw.githubusercontent.com/datamaker/opentunnel/main/server-rust/schema.sql -o schema.sql # Create docker-compose.yml cat > docker-compose.yml << 'EOF' services: vpn: image: datamaker/opentunnel:rust container_name: opentunnel-vpn restart: unless-stopped network_mode: host cap_add: - NET_ADMIN devices: - /dev/net/tun:/dev/net/tun environment: - DB_HOST=localhost - DB_PORT=5432 - DB_NAME=vpn - DB_USER=vpn - DB_PASSWORD=${DB_PASSWORD} - JWT_SECRET=${JWT_SECRET} depends_on: db: condition: service_healthy db: image: postgres:15-alpine container_name: opentunnel-db restart: unless-stopped network_mode: host environment: - POSTGRES_USER=vpn - POSTGRES_PASSWORD=${DB_PASSWORD} - POSTGRES_DB=vpn volumes: - postgres_data:/var/lib/postgresql/data - ./schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U vpn -h localhost"] interval: 5s timeout: 5s retries: 5 volumes: postgres_data: EOF # Create .env file cat > .env << EOF DB_PASSWORD=$DB_PASSWORD JWT_SECRET=$JWT_SECRET EOF echo "Configuration files created." echo "" # ============================================ # Setup Host Networking (NAT & IP Forwarding) # ============================================ echo "Configuring host networking..." # Enable IP forwarding echo " Enabling IP forwarding..." sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1 # Make it persistent if [ -f /etc/sysctl.conf ]; then grep -q "^net.ipv4.ip_forward" /etc/sysctl.conf || echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf fi echo " IP forwarding enabled." # Setup NAT rules on host echo " Setting up NAT rules..." # Find default interface DEFAULT_IFACE=$(ip route | grep default | awk '{print $5}' | head -n1) if [ -z "$DEFAULT_IFACE" ]; then DEFAULT_IFACE="eth0" fi echo " Default interface: $DEFAULT_IFACE" # Remove old rules if exist (avoid duplicates) iptables -t nat -D POSTROUTING -s ${VPN_SUBNET}/24 -o $DEFAULT_IFACE -j MASQUERADE 2>/dev/null || true iptables -D FORWARD -s ${VPN_SUBNET}/24 -j ACCEPT 2>/dev/null || true iptables -D FORWARD -d ${VPN_SUBNET}/24 -j ACCEPT 2>/dev/null || true # Add NAT rules iptables -t nat -A POSTROUTING -s ${VPN_SUBNET}/24 -o $DEFAULT_IFACE -j MASQUERADE iptables -A FORWARD -s ${VPN_SUBNET}/24 -j ACCEPT iptables -A FORWARD -d ${VPN_SUBNET}/24 -j ACCEPT iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT 2>/dev/null || true echo " NAT rules configured." # Save iptables rules (if iptables-persistent is installed) if command -v netfilter-persistent >/dev/null 2>&1; then netfilter-persistent save 2>/dev/null || true fi echo "" echo "Pulling Docker images..." docker pull $DOCKER_IMAGE docker pull postgres:15-alpine echo "" echo "Starting services..." docker compose up -d # Wait for PostgreSQL to be ready echo "" echo "Waiting for database to be ready..." for i in {1..30}; do if docker exec opentunnel-db pg_isready -U vpn >/dev/null 2>&1; then echo "Database is ready!" break fi echo " Waiting... ($i/30)" sleep 2 done # Initialize database schema echo "" echo "Initializing database schema..." docker exec -i opentunnel-db psql -U vpn -d vpn << 'SCHEMA_EOF' -- Enable UUID extension CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- Users table CREATE TABLE IF NOT EXISTS users ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), username VARCHAR(50) UNIQUE NOT NULL, password_hash VARCHAR(255) NOT NULL, email VARCHAR(100), is_active BOOLEAN DEFAULT true, max_connections INT DEFAULT 3, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); -- Active sessions table CREATE TABLE IF NOT EXISTS sessions ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, assigned_ip VARCHAR(15) NOT NULL, client_ip VARCHAR(45), client_platform VARCHAR(20) NOT NULL, client_version VARCHAR(20), connected_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, disconnected_at TIMESTAMP WITH TIME ZONE, last_activity TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, bytes_sent BIGINT DEFAULT 0, bytes_received BIGINT DEFAULT 0, UNIQUE(assigned_ip) ); -- Connection logs table CREATE TABLE IF NOT EXISTS connection_logs ( id SERIAL PRIMARY KEY, user_id UUID REFERENCES users(id) ON DELETE SET NULL, session_id UUID, event_type VARCHAR(20) NOT NULL CHECK (event_type IN ('connect', 'disconnect', 'auth_fail', 'error')), client_ip VARCHAR(45), client_platform VARCHAR(20), details TEXT, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); -- Indexes for performance CREATE INDEX IF NOT EXISTS idx_sessions_user_id ON sessions(user_id); CREATE INDEX IF NOT EXISTS idx_sessions_assigned_ip ON sessions(assigned_ip); CREATE INDEX IF NOT EXISTS idx_sessions_last_activity ON sessions(last_activity); CREATE INDEX IF NOT EXISTS idx_connection_logs_user_id ON connection_logs(user_id); CREATE INDEX IF NOT EXISTS idx_connection_logs_created_at ON connection_logs(created_at); CREATE INDEX IF NOT EXISTS idx_connection_logs_event_type ON connection_logs(event_type); -- Function to update updated_at timestamp CREATE OR REPLACE FUNCTION update_updated_at_column() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = CURRENT_TIMESTAMP; RETURN NEW; END; $$ language 'plpgsql'; -- Trigger for users table DROP TRIGGER IF EXISTS update_users_updated_at ON users; CREATE TRIGGER update_users_updated_at BEFORE UPDATE ON users FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); -- No VPN users are seeded — shipping a known default password on a live VPN is -- unsafe. Create your first user from the admin panel after install. SCHEMA_EOF echo "Database schema initialized!" # Restart VPN container to pick up database echo "" echo "Restarting VPN server..." docker restart opentunnel-vpn sleep 5 # Check if VPN is running if docker ps | grep -q opentunnel-vpn; then echo "" echo "========================================" echo " OpenTunnel VPN installed successfully!" echo "========================================" echo "" echo " VPN Server: $(hostname -I 2>/dev/null | awk '{print $1}' || echo 'your-server-ip'):1194" echo "" echo " Next step — create your first VPN user:" echo " Set ADMIN_PASSWORD (and/or ADMIN_SSO_EMAILS) in $INSTALL_DIR/.env," echo " restart, then open the admin panel and add users." echo "" echo " NAT Status:" echo " Interface: $DEFAULT_IFACE" echo " Subnet: ${VPN_SUBNET}/24" iptables -t nat -L POSTROUTING -n | grep -q "$VPN_SUBNET" && echo " MASQUERADE: OK" || echo " MASQUERADE: Check required" echo "" echo " Management commands:" echo " Status: docker ps" echo " Logs: docker logs -f opentunnel-vpn" echo " Stop: cd $INSTALL_DIR && docker compose down" echo " Start: cd $INSTALL_DIR && docker compose up -d" echo "" echo " Database password saved in: $INSTALL_DIR/.env" echo "" else echo "" echo "Warning: VPN container may not have started correctly." echo "Check logs with: docker logs opentunnel-vpn" fi |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |