launchctl 模板:保存为 "/Library/LaunchDaemons/me.meowproxy.meow.plist"
/Users/xxx/ 替换为你的用户名
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>me.meowproxy.meow</string>
<key>ProgramArguments</key>
<array>
<string>/Users/xxx/MEOW</string>
<string>-rc=/Users/xxx/.meow/rc</string>
</array>
<key>RunAtLoad</key>
<true />
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>/Users/xxx</string>
</dict>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>80480</integer>
</dict>
<key>StandardErrorPath</key>
<string>/var/log/meow.log</string>
<key>StandardOutPath</key>
<string>/var/log/meow.log</string>
</dict>
</plist>
shell script :
alias meowon='sudo launchctl load /Library/LaunchDaemons/me.meowproxy.meow.plist'
alias meowoff='sudo launchctl unload /Library/LaunchDaemons/me.meowproxy.meow.plist'
我的 launchctl 配置为 sudo 免密码,所以可以使用以下脚本切换服务器(使用行号确定 server ):
proxy(){
unset LINE
unset SERVER
if [[ $1 ]]; then
if [[ $1 == "do" ]]; then
LINE=37
SERVER=DigitalOcean
elif [[ $1 == "bwg" ]]; then
LINE=39
SERVER=Bandwagon
elif [[ $1 == "bwgb" ]]; then
LINE=41
SERVER=Bandwagon-Aliyun-Bridge
fi
if [[ $LINE ]]; then
sed -i '' 's/^proxy =/# proxy =/' ~/.meow/rc
sed -i '' $LINE's/^# proxy =/proxy =/' ~/.meow/rc
meowoff && meowon
echo Changed MEOW proxy to $SERVER!
fi
else
LINE=$(awk '/^proxy =/ {print NR}' ~/.meow/rc)
if [[ $LINE == 37 ]]; then
SERVER=DigitalOcean
elif [[ $LINE == 39 ]]; then
SERVER=Bandwagon
elif [[ $LINE == 41 ]]; then
SERVER=Bandwagon-Aliyun-Bridge
fi
echo current use Proxy $SERVER!
meowoff && meowon
echo MEOW restarted!
fi
}
查看日志:
tail -n 500 /var/log/meow.log