From dcc947252f9b10d0cd433fd51f8492cbe1f3d8c6 Mon Sep 17 00:00:00 2001 From: BPDL <73742154+bpdl1688@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:59:03 +0800 Subject: [PATCH] Delete vpn-kill-switch.sh Replaced by 03-kill-switch.sh which is based on this script originally. --- vpn-kill-switch.sh | 61 ---------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 vpn-kill-switch.sh diff --git a/vpn-kill-switch.sh b/vpn-kill-switch.sh deleted file mode 100644 index 957b52b..0000000 --- a/vpn-kill-switch.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - - ############################################################################################################################## -## ## -## This script kills the internet connectivity should the VPN connection, once established, drop. ## -## To enable networking again using the terminal, use: $ nmcli networking on ## -## ## -## This script relies on the package 'network-manager' to disable the network, and on 'libnotify-bin' to send notifications. ## -## This script does *not* need root permissions (in common system configurations). ## -## ## -## This script was written for and tested on Debian 9 Stretch, but should work on most Debian derivates. ## -## As the LICENSE file says, this script is distributed under GPLv3. ## -## ## -############################################################################################################################## - - -INTERFACE="tun0" ## default tun0 - the vpn interface that will be monitored. -VPN_EXISTS_CHECK="30" ## default 30 - the time to wait between scans for an active VPN connection -VPN_DROPPED_CHECK="0.25" ## default 0.25 - the time to wait for the next check whether the VPN interface still exists - -ECHO="0" ## set to "1" if you want/need terminal output. - - -## the script will run in an infinite loop. -while : -do - - ## first, the script will check if there's a VPN connection to be monitored. - if ! [[ $(ip addr | grep $INTERFACE) = "" ]]; then - - ## if $INTERFACE exists, there is a VPN connection. - notify-send "VPN connection was found and will be monitored." - if [[ $ECHO == "1" ]]; then echo "[$(date +%H:%M:%S)]: VPN found; monitoring."; fi - - ## if a VPN connection was detected, it will be watched using an infinite loop. - while : - do - ## let's check if the tun0 interface is still there... - if [[ $(ip addr | grep $INTERFACE) = "" ]]; then - - ## Oops! the $INTERFACE interface vanished, quickly kill networking and notify the user. - nmcli networking off - notify-send "VPN interface vanished; Network connectivity has been disabled." - if [[ $ECHO == "1" ]]; then echo "[$(date +%H:%M:%S)]: VPN died; networking disabled."; fi - - ## As the network connection was killed, we can stop looking if the interface still exists - break - fi - - ## if $INTERFACE is still there... check again after the time specified in $VPN_DROPPED_CHECK passed. - if [[ $ECHO == "1" ]]; then echo "[$(date +%H:%M:%S)]: VPN is ok."; fi - sleep $VPN_DROPPED_CHECK - done - - fi - - ## if the script reaches this point, there's no VPN connection at the time. - ## the script will wait the time set in $VPN_EXISTS_CHECK for the next check. - sleep $VPN_EXISTS_CHECK - -done