#!/bin/sh# Log file pathlog_file="/var/log/restart_vpn.log"# Timestamptimestamp=$(date +"%Y-%m-%d %T")# Redirect stdout and stderr to the log fileexec >> "$log_file" 2>&1echo "=== Script started at: $timestamp ==="echo "Restarting WireGuard and OpenVPN..."# Wait 20 seconds before running the scriptsleep 20# Stop WireGuard and OpenVPN services - adjust the OpenVPN numbers to whatever client is relevant to your setuppluginctl -s wireguard stoppluginctl -s openvpn stop 3pluginctl -s openvpn stop 4# Wait for a few secondssleep 5# Start WireGuardpluginctl -s wireguard start# Wait for a 15 secondssleep 15# Start OpenVPN connection client3pluginctl -s openvpn start 3# Wait for a 15 secondssleep 15# Start OpenVPN connection client4pluginctl -s openvpn start 4echo "done."
chmod +x 93-restart-vpn