#!/bin/bash # Function to ask for confirmation confirm() { read -p "Do you want to flush iptables and restart ALL wireguard tunnels? (y/n): " choice case "$choice" in y|Y ) return 0;; n|N ) echo "Script aborted."; exit 1;; * ) echo "Invalid input. Please enter 'y' or 'n'."; confirm;; esac } # Confirmation prompt confirm # Flush iptables rules iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X # Set default policies to ACCEPT iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT # Execute other commands if confirmed iptables -L -v -n ip6tables -L -n -v iptables -t nat -L -n -v ip6tables -t nat -L -n -v sudo journalctl -u INBOUND_TRAFFIC --vacuum-size=100G sudo journalctl -u OUTBOUND_TRAFFIC --vacuum-size=100G systemctl restart wg-quick@wg0.service systemctl restart wg-quick@wg1.service systemctl restart wg-quick@wg2.service echo "Script executed successfully."