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:
54
lib/utils.sh
Normal file
54
lib/utils.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/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)
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
echo "[INFO] $1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
echo "[WARN] $1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
echo "[ERROR] $1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
fatal_error() {
|
||||
log_error "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
fatal_error "This script must be run as root."
|
||||
fi
|
||||
}
|
||||
|
||||
show_banner() {
|
||||
clear
|
||||
echo -e "${BLUE}"
|
||||
echo "========================================================================="
|
||||
echo " WireGuard Secure Installer Enterprise"
|
||||
echo " (c) 2025 Muhammad Fadhila Abiyyu Faris"
|
||||
echo " https://github.com/fadhila36/wireguard-secure-installer"
|
||||
echo "========================================================================="
|
||||
echo -e "${NC}"
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "An error occurred. Check $LOG_FILE for details."
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user