How vpn-vendor/vpn works
Project type and purpose
• This is a server-provisioning automation script (vpn.sh) written in Bash.
• Its goal is to install, configure, and manage VPN services (WireGuard, OpenVPN), network tools, a local web interface, and an optional Telegram bot for remote control.
High-level architecture
• The entire system is driven by a single Bash script (vpn.sh) that executes in sequence on an Ubuntu 22.04 host.
• It interacts with:
• The OS package manager (apt) to install/remove packages.
• System services (systemd, iptables).
• Networking components (WireGuard, OpenVPN, DHCP).
• A local web server (Apache2) for VPN selection.
• An optional Python-based Telegram bot.
Main components and relationships
A. Orchestrator (vpn.sh) – central component
• Executed with root privileges.
• Calls apt, systemctl, iptables, resolvconf, etc.
B. Package Manager & System
• apt / dpkg: installs packages listed in the script.
• systemd: enables & starts services (isc-dhcp-server, network-manager, openvpn, wg-quick@…).
• iptables-persistent: stores firewall rules applied by the script.
C. Networking Services
• wireguard: VPN tunnel interface(s).
• openvpn: VPN daemon(s).
• isc-dhcp-server: DHCP assignments on internal nets (if used).
• network-manager: optional, for GUI networks.
D. Local Web Interface
• apache2 serves a simple site letting users switch between VPN configs.
• The script deploys config files to /var/www/html (or similar) and adjusts Apache vhosts.
E. Telegram Bot (optional)
• A small Python utility installed via apt.
• Interacts with Telegram’s API to allow remote server commands.
Interactions:
User → vpn.sh CLI
vpn.sh → apt → install/remove packages
vpn.sh → systemctl → enable/start services
vpn.sh → iptables → apply firewall rules
vpn.sh → writes configs → /etc/openvpn/, /etc/wireguard/, /var/www/html/
apache2 ← serves UI ← User’s browser
python-telegram-bot ← communicates ← Telegram API
Architectural patterns and principles
• Imperative provisioning script (no agents, one-shot).
• Separation of concerns: package installation, service configuration, UI deployment, cleanup.
• Idempotence emphasis: check before installing/removing packages.
• Optional components guarded by OS checks (Ubuntu 22.04 vs others).