Last active
December 20, 2016 12:25
-
-
Save naodesu/9209133 to your computer and use it in GitHub Desktop.
Скрипт для получения списков запрещённых URL через API сайта antizapret.info и генерации серверного конфига для openvpn.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CONF=/etc/openvpn/home/client-config/DEFAULT | |
IP_URL=http://api.antizapret.info/group.php | |
trap cleanup EXIT | |
cleanup() { | |
rm $NEW_CONF 2>/dev/null | |
} | |
replace() { | |
mv -f $NEW_CONF $CONF | |
chmod 644 $CONF | |
#kill -HUP `cat /var/run/openvpn.home.pid` 2>/dev/null | |
#/etc/init.d/openvpn.home --ifstarted restart | |
} | |
NEW_CONF=$(mktemp) | |
wget -q -O - $IP_URL \ | |
| egrep -o '\b([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}\b' \ | |
| awk '{print "push \"route " $0 "\""}' > $NEW_CONF | |
if [ ! -s $NEW_CONF ] ; then | |
exit 1 | |
fi | |
if [ ! -e $CONF ] ; then | |
replace | |
exit $? | |
fi | |
if diff -q $CONF $NEW_CONF >/dev/null ; then | |
true # nothing todo | |
else | |
replace | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment