Skip to content

Instantly share code, notes, and snippets.

@Femtometer
Last active July 19, 2016 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Femtometer/50a014c30a0919b7a48a372c8a95f51b to your computer and use it in GitHub Desktop.
Save Femtometer/50a014c30a0919b7a48a372c8a95f51b to your computer and use it in GitHub Desktop.
Command line PAC generate code for OSX
#!/bin/bash
// Generate gfwlist.js for ShadowsocksX
// Install gfwlist2pac in python2.7
// Download gfwlist.txt from github
// Use "sh code.sh" to generate.
PROXY="127.0.0.1:1080"
TXTROOT="/Users/USRNAME/desktop"
# 下载PAC与SH文件同级目录
check_module_installed()
{
pip2 list | grep gfwlist2pac &> /dev/null
if [ $? -eq 1 ]; then
echo "Installing gfwlist2pac."
pip2 install gfwlist2pac
fi
}
update_gfwlist()
{
ls | grep gfwlist.txt
cd ~/.ShadowsocksX || exit 1
if [ -f "gfwlist.js" ]; then
echo "Del old file."
mv gfwlist.js ~/.Trash
fi
gfwlist2pac \
--input $TXTROOT/gfwlist.txt \
--file ./gfwlist.js \
--proxy "SOCKS5 $PROXY; SOCKS $PROXY; DIRECT;" \
--precise
echo "PAC Updated."
}
check_module_installed
update_gfwlist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment