Skip to content

Instantly share code, notes, and snippets.

@kizzx2 kizzx2/start-ss.sh
Last active Jul 17, 2018

Embed
What would you like to do?
Simple script to start Shadowsocks + GFWList and configures OS X system preferences to use it
#!/bin/sh
# Simple script to start Shadowsocks + GFWList and configures
# OS X system preferences to use it
if [[ $(id -u) -ne 0 ]]
then
sudo sh $0
exit
fi
sslocal -c $HOME/.shadowsocks.json -v &
pid=$!
sleep 3
function on_exit() {
echo "Killing sslocal with PID $pid"
kill $pid
echo "Disabling proxy for 'Wi-Fi'..."
/usr/sbin/networksetup -setautoproxystate Wi-Fi off
}
genpac --gfwlist-url=https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -o $HOME/ss-gfwlist.pac -p 'SOCKS5 127.0.0.1:1080' --gfwlist-proxy='SOCKS5 127.0.0.1:1080'
echo "Set proxy for 'Wi-Fi' to file:///$HOME/ss-gfwlist.pac..."
trap on_exit EXIT
/usr/sbin/networksetup -setautoproxyurl Wi-Fi file:///$HOME/ss-gfwlist.pac
/usr/sbin/networksetup -setautoproxystate Wi-Fi on
echo "Ready..."
wait $pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.