43 lines
1.4 KiB
Bash
43 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# MeshVPN Server Setup Script
|
|
# This script installs Go, Redis, PostgreSQL, and configures the firewall.
|
|
|
|
set -e
|
|
|
|
echo "🚀 Starting MeshVPN Coordinator Setup..."
|
|
|
|
# 1. Update System
|
|
sudo apt-get update
|
|
|
|
# 2. Install Dependencies
|
|
echo "📦 Installing system dependencies..."
|
|
sudo apt-get install -y golang-go redis-server postgresql postgresql-contrib ufw curl git
|
|
|
|
# 3. Configure PostgreSQL
|
|
echo "🐘 Configuring PostgreSQL..."
|
|
sudo systemctl start postgresql
|
|
sudo systemctl enable postgresql
|
|
# Create database and user (Simplified for setup)
|
|
sudo -u postgres psql -c "CREATE USER meshvpn WITH PASSWORD 'password';" || echo "User already exists"
|
|
sudo -u postgres psql -c "CREATE DATABASE meshvpn OWNER meshvpn;" || echo "DB already exists"
|
|
|
|
# 4. Configure Redis
|
|
echo "⚡ Configuring Redis..."
|
|
sudo systemctl start redis-server
|
|
sudo systemctl enable redis-server
|
|
|
|
# 5. Firewall Configuration (UFW)
|
|
echo "🛡️ Configuring Firewall (UFW)..."
|
|
sudo ufw allow 22/tcp # SSH
|
|
sudo ufw allow 3478/udp # STUN
|
|
sudo ufw allow 50051/tcp # Coordinator gRPC
|
|
sudo ufw --force enable
|
|
|
|
echo "-------------------------------------------------------"
|
|
echo "✅ Server Setup Complete!"
|
|
echo "Ports opened: 3478/UDP (STUN), 50051/TCP (Coordinator)"
|
|
echo "Redis and Postgres are running."
|
|
echo "Now navigate to /server and run: go run main.go"
|
|
echo "-------------------------------------------------------"
|