From e7beaa224432d778645d873f66e12bd5860adf1f Mon Sep 17 00:00:00 2001 From: QiuSimons <45143996+QiuSimons@users.noreply.github.com> Date: Sat, 2 Apr 2022 12:10:31 +0800 Subject: [PATCH] Add update check --- root/etc/mosdns/mosupdater.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/root/etc/mosdns/mosupdater.sh b/root/etc/mosdns/mosupdater.sh index 785c654..4e73c05 100755 --- a/root/etc/mosdns/mosupdater.sh +++ b/root/etc/mosdns/mosupdater.sh @@ -7,18 +7,28 @@ source /etc/mosdns/library.sh TMPDIR=$(mktemp -d) || exit 1 getdat geoip.dat getdat geosite.dat -find "$TMPDIR"/* -size -20k -exec rm {} \; +if [ "$(grep -o CN "$TMPDIR"/geoip.dat | wc -l)" -eq "0" ]; then + rm -rf "$TMPDIR"/geoip.dat +fi +if [ "$(grep -o .com "$TMPDIR"/geosite.dat | wc -l)" -lt "1000" ]; then + rm -rf "$TMPDIR"/geosite.dat +fi cp -rf "$TMPDIR"/* /usr/share/v2ray rm -rf "$TMPDIR" syncconfig=$(uci -q get mosdns.mosdns.syncconfig) if [ "$syncconfig" -eq 1 ]; then - TMPDIR=$(mktemp -d) || exit 2 - getdat def_config.yaml - getdat serverlist.txt - find "$TMPDIR"/* -size -2k -exec rm {} \; - cp -rf "$TMPDIR"/* /etc/mosdns - rm -rf /etc/mosdns/serverlist.bak -fi + TMPDIR=$(mktemp -d) || exit 2 + getdat def_config.yaml + getdat serverlist.txt + if [ "$(grep -o .com "$TMPDIR"/serverlist.txt | wc -l)" -lt "1000" ]; then + rm -rf "$TMPDIR"/serverlist.txt + fi + if [ "$(grep -o plugin "$TMPDIR"/def_config.yaml | wc -l)" -eq "0" ]; then + rm -rf "$TMPDIR"/def_config.yaml + fi + cp -rf "$TMPDIR"/* /etc/mosdns + rm -rf /etc/mosdns/serverlist.bak +fi exit 0