Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Last active July 17, 2018 10:35
Show Gist options
  • Save kizzx2/ac826ab2d4955032e8e1 to your computer and use it in GitHub Desktop.
Save kizzx2/ac826ab2d4955032e8e1 to your computer and use it in GitHub Desktop.
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