zapret/files/huawei/E8372/run-zapret-hostlist
2021-03-04 14:30:38 +03:00

36 lines
797 B
Plaintext
Executable File

#!/system/bin/busybox sh
# download hostlist from http(s) (need curl, its absent by default),
# feed it to zapret. save flash write cycles
u="https://your.host.com/censorship/hoslist.txt"
SCRIPT=$(readlink -f "$0")
EXEDIR=$(dirname "$SCRIPT")
d=/data/censorship
[ -d $d ] || mkdir $d
f=$d/hostlist.txt
t=/hostlist.txt
curl -k --fail --max-time 10 -o "$t" "$u" && {
if [ -s "$t" ]; then
m1=$(md5sum "$t" | cut -d ' ' -f 1)
m2=$(md5sum "$f" | cut -d ' ' -f 1)
echo $m1 $m2
if [ -z "$m2" ] || [ "$m1" != "$m2" ]; then
echo updating hostlist
cp -f "$t" "$f"
else
echo hostlist was not changed. keeping old copy
fi
else
echo downloaded hostlist is empty. disabling zapret
rm "$f"
fi
}
rm -f "$t"
"$EXEDIR/unzapret"
[ -s "$f" ] && exec "$EXEDIR/zapret" "--hostlist=$f"