Skip to content

Instantly share code, notes, and snippets.

@haiyon
Last active March 15, 2018 03:35
Show Gist options
  • Select an option

  • Save haiyon/67e3e024843324f102a53cb8008e88a4 to your computer and use it in GitHub Desktop.

Select an option

Save haiyon/67e3e024843324f102a53cb8008e88a4 to your computer and use it in GitHub Desktop.
#!/bin/sh
opkg update
for ipk in $(opkg list-upgradable | awk '$1!~/^kmod|^Multiple/{print $1}'); do
opkg upgrade $ipk
done
#!/bin/sh
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
wget --spider --quiet --tries=1 --timeout=10 www.google.com
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] No Problem.'
exit 0
else
wget --spider --quiet --tries=1 --timeout=10 www.baidu.com
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] Problem decteted, restarting shadowsocks.'
/etc/init.d/shadowsocks restart
else
echo '['$LOGTIME'] Network Problem. restarting chinadns.'
/etc/init.d/chinadns restart
fi
fi
#!/bin/sh
set -e -o pipefail
wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | \
awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > \
/tmp/chinadns_chnroute.txt
mv /tmp/chinadns_chnroute.txt /etc/
if pidof ss-redir>/dev/null; then
/etc/init.d/shadowsocks restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment