1 Star 0 Fork 3

wangzhen/Rythem

forked from Gitee 极速下载/Rythem 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
setupproxy 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
panxz 提交于 2012-09-14 09:34 . use pac to config mac proxy
#! /bin/bash -e
# usage
# setupproxy [serviceName] [cmd] <other arguments>
# cmd:
# setHttpAndHttpsProxy
# setHttpProxy
# setHttpsProxy
# setHttpAndHttpsProxyState
# setHttpProxyState
#
#
function setHttpProxy(){
sudo networksetup -setwebproxy $1 $2 $3
}
function setHttpsProxy(){
sudo networksetup -setsecurewebproxy $1 $2 $3
}
function setHttpAndHttpsProxy(){
setHttpProxy $1 $2 $3
setHttpsProxy $1 $2 $3
}
function setHttpProxyState(){
sudo networksetup -setwebproxystate $1 $2
}
function setHttpsProxyState(){
sudo networksetup -setsecurewebproxystate $1 $2
}
function setHttpAndHttpsProxyState(){
setHttpProxyState $1 $2 $3
setHttpsProxyState $1 $2 $3
}
function setAutoProxyState(){
sudo networksetup -setautoproxystate $1 $2
}
function setAutoProxyUrl(){
sudo networksetup -setautoproxyurl $1 $2
}
function onlyATest(){
tmp=`networksetup -getwebproxy Wi-Fi | grep "Enabled.*\([YesNo]\)$"`
#echo "after"
#echo $tmp
enable="on"
if test "$tmp" = "Enabled: No";
then
enable="off"
fi
#echo $enable
sudo networksetup -setautoproxystate $1 $enable
if test $? -gt 0; then
#echo $?
#cause pwd prompt
networksetup -setautoproxystate $1 $enable
fi
}
if [ "$#" -lt "2" ]
then
echo "arguments need more"
exit 1
else
cmd=$1
shift 1;
declare -F ${cmd} > /dev/null
if test $? -eq 0
then
onlyATest $*
${cmd} $*
exit $?
else
echo "no such function ${cmd}"
exit 1
fi
exit 0
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/JohnWangTongZhen/Rythem.git
git@gitee.com:JohnWangTongZhen/Rythem.git
JohnWangTongZhen
Rythem
Rythem
master

搜索帮助