feat: add wireguard secure installer with modular architecture
This commit introduces a new WireGuard VPN installer with enterprise-grade security features. The installer includes: - Zero-touch installation with automatic configuration - Modular architecture for maintainability (separate lib files) - Client management interface with bandwidth monitoring - Support for multiple Linux distributions - Secure defaults and hardened configurations The implementation provides a complete solution for deploying WireGuard VPN servers with minimal user interaction while maintaining security best practices.
This commit is contained in:
52
install.sh
Normal file
52
install.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
# WireGuard Secure Installer
|
||||
# Copyright (c) 2025 Muhammad Fadhila Abiyyu Faris
|
||||
# GitHub: [github.com/fadhila36/wireguard-secure-installer](https://github.com/fadhila36/wireguard-secure-installer)
|
||||
|
||||
# Set strict mode
|
||||
set -e
|
||||
|
||||
# Load Config and Libraries
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/config.env"
|
||||
source "$SCRIPT_DIR/lib/utils.sh"
|
||||
source "$SCRIPT_DIR/lib/network.sh"
|
||||
source "$SCRIPT_DIR/lib/os_detect.sh"
|
||||
source "$SCRIPT_DIR/lib/wg_core.sh"
|
||||
|
||||
# Trap for cleanup
|
||||
trap cleanup EXIT
|
||||
|
||||
# Main Logic
|
||||
main() {
|
||||
check_root
|
||||
show_banner
|
||||
|
||||
log_info "Starting Zero-Touch Installation..."
|
||||
|
||||
check_os
|
||||
install_dependencies
|
||||
|
||||
detect_main_interface
|
||||
detect_public_ip
|
||||
|
||||
configure_firewall
|
||||
|
||||
generate_keys
|
||||
generate_server_config
|
||||
start_wireguard
|
||||
|
||||
# Create default admin client (IP .2) if not exists
|
||||
if ! grep -q "### Client: $CLIENT_NAME" "$WG_CONFIG"; then
|
||||
create_client_config "$CLIENT_NAME" "2"
|
||||
else
|
||||
log_info "Default client '$CLIENT_NAME' already exists. Skipping creation."
|
||||
fi
|
||||
|
||||
log_info "Installation Completed Successfully!"
|
||||
echo -e "${GREEN}WireGuard is installed and running.${NC}"
|
||||
echo -e "Client Config: ${YELLOW}$INSTALL_DIR/clients/$CLIENT_NAME.conf${NC}"
|
||||
echo -e "Manage script: ${YELLOW}$INSTALL_DIR/manage.sh${NC}"
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user