设置代理
####
# /usr/bin/proxy
start(){
# 开启浏览器代理
gsettings set org.gnome.system.proxy.http host '1xx.1xx.1x.1xx'
gsettings set org.gnome.system.proxy.http port 1xx
gsettings set org.gnome.system.proxy mode 'manual'
# 开启终端代理
sed -i 's/export http_proxy=""/export http_proxy=http:\/\/1xx.1xx.1.1xx:1xx/' ~/.bashrc
sed -i 's/export https_proxy=""/export https_proxy=http:\/\/1xx.1xx.1.1xx:1xx/' ~/.bashrc
source ~/.bashrc
# 说明: 开启成功之后,git也是走代理的
}
stop(){
# 关闭浏览器代理
gsettings set org.gnome.system.proxy mode 'none'
# 关掉终端代理
sed -i 's/export http_proxy=http:\/\/1xx.1xx.1.1xx:1xx/export http_proxy=""/' ~/.bashrc
sed -i 's/export https_proxy=http:\/\/1xx.1xx.1.1xx:1xx/export http_proxy=""/' ~/.bashrc
source ~/.bashrc
}
restart(){
stop
start
}
case "$1" in
"start")
start
;;
"stop")
stop
;;
"restart")
restart
;;
*)
echo "$0 start|stop|restart"
esac
查看本机ip
curl ipinfo.io