Quellcode durchsuchen

feature: upgrade protect checkbox

rufengsuixing vor 5 Jahren
Ursprung
Commit
8a97e18702
2 geänderte Dateien mit 19 neuen und 11 gelöschten Zeilen
  1. 15 5
      luasrc/model/cbi/AdGuardHome/base.lua
  2. 4 6
      root/etc/init.d/AdGuardHome

+ 15 - 5
luasrc/model/cbi/AdGuardHome/base.lua

@@ -191,10 +191,18 @@ o.default     = ""
 o.datatype    = "string"
 o.template = "AdGuardHome/AdGuardHome_chpass"
 o.optional = true
----- database protect
-o = s:option(Flag, "keepdb", translate("Keep database when system upgrade"))
-o.default = 0
-o.optional = true
+---- upgrade protect
+o = s:option(MultiValue, "upprotect", translate("Keep files when system upgrade"))
+o:value("$binpath",translate("core bin"))
+o:value("$configpath",translate("config file"))
+o:value("$logfile",translate("log file"))
+o:value("$workdir/data/sessions.db",translate("sessions.db"))
+o:value("$workdir/data/stats.db",translate("stats.db"))
+o:value("$workdir/data/querylog.json",translate("querylog.json"))
+o:value("$workdir/data/filters",translate("filters"))
+o.widget = "checkbox"
+o.default = nil
+o.optional=true
 ---- wait net on boot
 o = s:option(Flag, "waitonboot", translate("Boot delay until network ok"))
 o.default = 1
@@ -207,13 +215,15 @@ local name
 o:value("filters","filters")
 o:value("stats.db","stats.db")
 o:value("querylog.json","querylog.json")
+o:value("sessions.db","sessions.db")
 o1:depends ("backupfile", "filters")
 o1:depends ("backupfile", "stats.db")
 o1:depends ("backupfile", "querylog.json")
+o1:depends ("backupfile", "sessions.db")
 for name in fs.glob(workdir.."/data/*")
 do
 	name=fs.basename (name)
-	if name~="filters" and name~="stats.db" and name~="querylog.json" then
+	if name~="filters" and name~="stats.db" and name~="querylog.json" and name~="sessions.db" then
 		o:value(name,name)
 		o1:depends ("backupfile", name)
 	end

+ 4 - 6
root/etc/init.d/AdGuardHome

@@ -421,19 +421,17 @@ start_service() {
 	config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
 	config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
 
-	echo -e "$configpath\n$binpath">/lib/upgrade/keep.d/luci-app-adguardhome
 	mkdir -p ${binpath%/*}
 	ADDITIONAL_ARGS="$ADDITIONAL_ARGS -c $configpath"
 	ADDITIONAL_ARGS="$ADDITIONAL_ARGS -w $workdir"
 	config_get httpport $CONFIGURATION httpport 3000
 	ADDITIONAL_ARGS="$ADDITIONAL_ARGS -p $httpport"
 
-	echo -e "$configpath\n$binpath">/lib/upgrade/keep.d/luci-app-adguardhome
 	# hack to save config file when upgrade system
-	config_get keepdb $CONFIGURATION keepdb 0
-	if [ "$keepdb" -eq 1 ]; then
-		echo -e "$workdir/data/sessions.db\n$workdir/data/stats.db\n$workdir/data/querylog.json">>/lib/upgrade/keep.d/luci-app-adguardhome
-	fi
+	config_get upprotect $CONFIGURATION upprotect ""
+	eval upprotect=${upprotect// /\\n}
+	echo -e "$upprotect">/lib/upgrade/keep.d/luci-app-adguardhome
+	
 	config_get logfile $CONFIGURATION logfile ""
 	if [ -n "$logfile" ]; then
 		ADDITIONAL_ARGS="$ADDITIONAL_ARGS -l $logfile"