Skip to content

Instantly share code, notes, and snippets.

@uvwild
Last active February 19, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uvwild/30f40a90cbcb27876fbdda019ef1f3e6 to your computer and use it in GitHub Desktop.
Save uvwild/30f40a90cbcb27876fbdda019ef1f3e6 to your computer and use it in GitHub Desktop.
change proxy settings via dconf in linux
#!/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