Last active
April 7, 2019 07:49
-
-
Save frgomes/544014b53e5384e00847da20b3e1da5b to your computer and use it in GitHub Desktop.
Debian - auto configure proxy when Network Manager connects an interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## see: http://github.com/frgomes/debian-bin/blob/master/bash_80proxy.sh | |
SCRIPT=/home/rgomes/bin/bash_80proxy.sh | |
## INTF is the network interface, either a wired one, wireless or any other type | |
INTF=enp8s0 | |
## DEFAULT_PROXY contains the HTTP_PROXY to be defined when INTF is connected | |
DEFAULT_PROXY=http://127.0.0.1:3128/ | |
if [ "$1" == $INTF ] ;then | |
source $SCRIPT | |
case "$2" in | |
up) | |
if [[ $( netstat -an | fgrep :3128 ) ]] ;then | |
unbound_local_zones_ifnet $INTF && sudo service unbound restart | |
proxy_on $DEFAULT_PROXY | |
else | |
unbound_local_zones && sudo service unbound restart | |
proxy_off | |
fi | |
;; | |
down) | |
unbound_local_zones && sudo service unbound restart | |
proxy_off | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suppose you have a wireless connection with SSID called OpenWRT-5G.
In this supposed scenario, perform the following steps: