Last active
February 19, 2019 07:39
-
-
Save uvwild/30f40a90cbcb27876fbdda019ef1f3e6 to your computer and use it in GitHub Desktop.
change proxy settings via dconf in linux
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 | |
######################################### | |
# handle proxy settings | |
# create link to this file using the case option below to create command to set a proxy | |
dconf_hosts="/system/proxy/http/host | |
/system/proxy/https/host | |
/system/proxy/socks/host" | |
dconf_ports="/system/proxy/http/port | |
/system/proxy/https/port | |
/system/proxy/socks/port" | |
dconf_keys="${dconf_hosts} ${dconf_ports} /system/proxy/ignore-hosts" | |
showproxy () { | |
for key in $dconf_keys | |
do | |
echo -en "$key=\t" | |
dconf read $key | |
done | |
} | |
setproxy () { | |
host=$1 | |
port=$2 | |
for key in $dconf_hosts | |
do | |
dconf write $key $host | |
done | |
for key in $dconf_ports | |
do | |
dconf write $key $port | |
done | |
for key in $dconf_keys | |
do | |
echo -en "$key=\t" | |
dconf read $key | |
done | |
} | |
case $(basename $0) in | |
showproxy.sh) | |
showproxy | |
;; | |
setoneproxy.sh) | |
setproxy "'1.2.3.4'" 1234 | |
;; | |
settwoproxy.sh) | |
setproxy "'5.6.7.8'" 5678 | |
;; | |
setthreeproxy.sh) | |
setproxy "'9.8.7.6'" 9876 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment