openwrt: save cache to disk when reboot system

This commit is contained in:
Nick Peng
2023-01-16 20:29:56 +08:00
parent ee4816da5c
commit 1f40577ef0
10 changed files with 61 additions and 6 deletions

View File

@@ -47,10 +47,13 @@ define Package/smartdns/conffiles
/etc/smartdns/address.conf
/etc/smartdns/blacklist-ip.conf
/etc/smartdns/custom.conf
/etc/smartdns/domain-block.list
/etc/smartdns/domain-forwarding.list
endef
define Package/smartdns/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/smartdns
$(INSTALL_DIR) $(1)/etc/smartdns/conf.d $(1)/etc/smartdns/domain-set
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smartdns $(1)/usr/sbin/smartdns
$(INSTALL_BIN) $(PKG_BUILD_DIR)/package/openwrt/files/etc/init.d/smartdns $(1)/etc/init.d/smartdns
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/address.conf $(1)/etc/smartdns/address.conf

View File

@@ -2,3 +2,5 @@
/etc/smartdns/address.conf
/etc/smartdns/blacklist-ip.conf
/etc/smartdns/custom.conf
/etc/smartdns/domain-block.list
/etc/smartdns/domain-forwarding.list

View File

@@ -19,4 +19,6 @@
default_prerm $0 $@
rm /var/etc/smartdns.conf -f
rm /var/etc/smartdns/smartdns.conf -f
rm /var/log/smartdns/ -fr
rm /etc/smartdns/smartdns.cache -f
exit 0

View File

@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
START=19
STOP=82
NAME=smartdns
USE_PROCD=1
SERVICE_USE_PID=1
@@ -536,6 +537,19 @@ load_service()
config_get bind_device_name "$section" "bind_device_name" "${lan_device}"
[ ! -z "$bind_device_name" ] && [ "$bind_device" = "1" ] && device="${bind_device_name}"
config_get cache_file "$section" "cache_file" "$SMARTDNS_CONF_DIR/smartdns.cache"
config_get_bool cache_persist "$section" "cache_persist" "0"
[ "$cache_persist" = "1" ] && {
conf_append "cache-persist" "yes"
conf_append "cache-file" "$cache_file"
}
[ "$cache_persist" = "0" ] && {
conf_append "cache-persist" "no"
[ -f "$cache_file" ] && rm -f "$cache_file"
}
config_get proxy_server "$section" "proxy_server" ""
[ -z "$proxy_server" ] || conf_append "proxy-server" "$proxy_server -name default-proxy"