Open void285 opened 1 year ago
#!/bin/sh -e [ -d /etc/chinadns-ng ] || mkdir /etc/chinadns-ng reload=0 for item in chnroute/chnroute chnroute/chnroute6 gfwlist/gfwlist chinalist/chinalist do file=${item##*/} localsize=`wc -c /etc/chinadns-ng/${file}.txt | awk '{print $1}'` remotesize=`curl -s -I https://raw.githubusercontent.com/pexcn/daily/gh-pages/${item}.txt | grep -i "Content-Length:" | awk '{print $2}'` if [ $localsize != $remotesize ]; then wget --no-dns-cache --no-check-certificate -4 https://raw.githubusercontent.com/pexcn/daily/gh-pages/${item}.txt -O /tmp/${file}.tmp && [ "$?" == "0" ] && mv -f /tmp/${file}.tmp /etc/chinadns-ng/${file}.txt && reload=1 && echo "update ${file}, size ${localsize} -> ${remotesize}" || "update ${file} failed" else echo "ignore ${file}, size ${localsize}" fi done if [ $reload == 1 ]; then /etc/init.d/chinadns-ng restart fi
I think check the hash will better, such as md5sum.
md5sum
Please achieve it, since write to nand/emmc is slow and fragile.