From c3b7847b59780145f592608187b00ff17dfeb831 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Sat, 25 Mar 2023 01:15:06 +0800 Subject: [PATCH] luci-app-mosdns: Clean `cache.dump` file when "Save Cache" is disabled --- luci-app-mosdns/root/etc/init.d/mosdns | 3 ++- .../root/{etc => usr/share}/mosdns/cache.dump | Bin 2 files changed, 2 insertions(+), 1 deletion(-) rename luci-app-mosdns/root/{etc => usr/share}/mosdns/cache.dump (100%) diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index fc3b4c7..02e8cfd 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -64,7 +64,8 @@ init_yaml() { s,maximum_ttl_custom,$maximum_ttl_custom,g; \ s,adblock,$adlist,g;s,remote_dns_pipeline,$enable_pipeline,g" \ /usr/share/mosdns/default.yaml > $CONF - [ "$dump_file" -eq 1 ] && sed -i "/lazy_cache_ttl/a\ dump_file: /etc/mosdns/cache.dump\n dump_interval: $dump_interval" $CONF + [ "$dump_file" -eq 1 ] && sed -i "/lazy_cache_ttl/a\ dump_file: /etc/mosdns/cache.dump\n dump_interval: $dump_interval" $CONF || \ + \cp -a /usr/share/mosdns/cache.dump /etc/mosdns/cache.dump echo "${local_dns}" > $tmpdir/local_dns.txt echo "${remote_dns}" > $tmpdir/remote_dns.txt sed -i -e '/- addr: local_dns/{r '$tmpdir/local_dns.txt -e';d};/- addr: remote_dns/{r '$tmpdir/remote_dns.txt -e';d}' \ diff --git a/luci-app-mosdns/root/etc/mosdns/cache.dump b/luci-app-mosdns/root/usr/share/mosdns/cache.dump similarity index 100% rename from luci-app-mosdns/root/etc/mosdns/cache.dump rename to luci-app-mosdns/root/usr/share/mosdns/cache.dump