luci-app-mosdns: fix multiple restart when database update

This commit is contained in:
sbwml 2023-09-27 14:20:20 +08:00
parent 547159caaa
commit 7d01c798fd

View File

@ -52,7 +52,7 @@ get_adlist() (
fi fi
) )
adlist_update() ( adlist_update() {
[ "$(uci -q get mosdns.config.adblock)" != 1 ] && exit 0 [ "$(uci -q get mosdns.config.adblock)" != 1 ] && exit 0
ad_source=$(uci -q get mosdns.config.ad_source) ad_source=$(uci -q get mosdns.config.ad_source)
AD_TMPDIR=$(mktemp -d) || exit 1 AD_TMPDIR=$(mktemp -d) || exit 1
@ -83,10 +83,9 @@ adlist_update() (
rm -rf /etc/mosdns/rule/adlist/* rm -rf /etc/mosdns/rule/adlist/*
\cp $AD_TMPDIR/* /etc/mosdns/rule/adlist \cp $AD_TMPDIR/* /etc/mosdns/rule/adlist
rm -rf "$AD_TMPDIR" rm -rf "$AD_TMPDIR"
restart_service
} }
fi fi
) }
geodat_update() ( geodat_update() (
TMPDIR=$(mktemp -d) || exit 1 TMPDIR=$(mktemp -d) || exit 1
@ -120,7 +119,7 @@ geodat_update() (
exit 1 exit 1
fi fi
rm -rf "$TMPDIR"/*.sha256sum rm -rf "$TMPDIR"/*.sha256sum
cp -f "$TMPDIR"/* /usr/share/v2ray \cp -a "$TMPDIR"/* /usr/share/v2ray
rm -rf "$TMPDIR" rm -rf "$TMPDIR"
) )
@ -179,7 +178,7 @@ case $script_action in
logfile_path logfile_path
;; ;;
"adlist_update") "adlist_update")
adlist_update adlist_update && [ "$has_update" -eq 1 ] && restart_service
;; ;;
"ecs_remote") "ecs_remote")
ecs_remote ecs_remote