Files
vpn-wireguard/lib/os_detect.sh
Muhammad Fadhila Abiyyu Faris 35ff83baca 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.
2025-11-30 14:55:15 +07:00

53 lines
1.5 KiB
Bash

#!/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)
check_os() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
VERSION_ID=$VERSION_ID
else
fatal_error "Cannot detect OS. /etc/os-release not found."
fi
log_info "Detected OS: $OS $VERSION_ID"
case "$OS" in
ubuntu|debian)
PKG_MANAGER="apt-get"
UPDATE_CMD="apt-get update"
INSTALL_CMD="apt-get install -y"
;;
centos|rhel|rocky|almalinux)
PKG_MANAGER="dnf"
UPDATE_CMD="dnf check-update" # dnf update is slow, check-update is enough to refresh metadata
INSTALL_CMD="dnf install -y"
;;
*)
fatal_error "Unsupported OS: $OS. Supported: Ubuntu, Debian, CentOS, Rocky, AlmaLinux."
;;
esac
}
install_dependencies() {
log_info "Installing dependencies..."
$UPDATE_CMD >> "$LOG_FILE" 2>&1
case "$OS" in
ubuntu|debian)
$INSTALL_CMD wireguard qrencode curl iptables >> "$LOG_FILE" 2>&1
;;
centos|rhel|rocky|almalinux)
$INSTALL_CMD epel-release >> "$LOG_FILE" 2>&1
$INSTALL_CMD wireguard-tools qrencode curl iptables-services >> "$LOG_FILE" 2>&1
;;
esac
if ! command -v wg >/dev/null; then
fatal_error "WireGuard installation failed."
fi
}