Browse Source

fix lost database on support filesystem

rufengsuixing 5 years ago
parent
commit
120bb31263
3 changed files with 42 additions and 27 deletions
  1. 1 1
      Makefile
  2. 2 2
      README.md
  3. 39 24
      root/etc/init.d/AdGuardHome

+ 1 - 1
Makefile

@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luci-app-adguardhome
 PKG_VERSION:=1.7
-PKG_RELEASE:=11
+PKG_RELEASE:=12
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 

+ 2 - 2
README.md

@@ -15,7 +15,7 @@
  - 手动修改配置文件(支持yaml编辑器)
  - 使用模板快速配置(没有配置文件时)
 #### 已知问题:
- - db数据库不支持放在比较特别的文件系统上比如 overlay data-stk-oo,请修改工作目录,本软件如果检测到overlay会自动ln(软连接)到/tmp,将会导致重启丢失dns数据库
+ - db数据库不支持放在不支持mmap的文件系统上比如 jffs2 data-stk-oo,请修改工作目录,本软件如果检测到jffs2会自动ln(软连接)到/tmp,将会导致重启丢失dns数据库
  - AdGuardHome 不支持ipset 设置,在使用ipset的情况下,无法替代dnsmasq只能作为dnsmasq上游存在,如果你想要这个功能就去投票吧<br>
  https://github.com/AdguardTeam/AdGuardHome/issues/1191
  - openwrt 19 出现了开关反了的问题,https://github.com/openwrt/luci/issues/3389 ,因为和以前版本的执行结果冲突暂时不做修复
@@ -38,7 +38,7 @@ Complex openwrt AdGuardHome luci
  - modify config manually(support yaml editor)
  - use template to fast config(when no config file)
 #### known issues:
- - db database not support some filesystem such as overlay and data-stk-oo,please modify work dir,if overlay is found,will auto ln (soft link)the dbs to /tmp ,will lost dns database after reboot
+ - db database not support filesystem which not support mmap such as jffs2 and data-stk-oo,please modify work dir,if jffs2 is found,will auto ln (soft link)the dbs to /tmp ,will lost dns database after reboot
  - AdGuardhome not support ipset,when we use ipset ,it can`t be the repacement of dnsmasq but the upstream of dnsmasq ,if you want it,vote for it.<br>
  https://github.com/AdguardTeam/AdGuardHome/issues/1191<br>
  - openwrt 19 found enable flag is reversed, https://github.com/openwrt/luci/issues/3389 ,not to fix it due to the different run result on old version op.

+ 39 - 24
root/etc/init.d/AdGuardHome

@@ -198,28 +198,42 @@ do_redirect()
 get_filesystem()
 {
 # print out path filesystem
-	echo $1 | awk '
-	BEGIN{
-	while (("mount"| getline ret) > 0)
-	{
-	split(ret,d);
-	fs[d[3]]=d[5];
-	}
-	}{
-	split($0,d,"/");
-	if ("/" in fs)
-	{ 
-	result=fs["/"];
-	}
-	for (i=2;i<=length(d);i++)
-	{
-	   p[i]=p[i-1]"/"d[i];
-	   if (p[i] in fs)
-		{ 
-		result=fs[p[i]];
-		}
-	}
-	print(result);}'
+    echo $1 | awk '
+    BEGIN{
+    while (("mount"| getline ret) > 0)
+    {
+    split(ret,d);
+    fs[d[3]]=d[5];
+    m=index(d[1],":")
+    if (m==0)
+    {
+        pt[d[3]]=d[1]
+    }else{
+        pt[d[3]]=substr(d[1],m+1)
+    }}}{
+    split($0,d,"/");
+    if ("/" in fs)
+    { 
+    result1=fs["/"];
+    }
+    if ("/" in pt)
+    { 
+    result2=pt["/"];
+    }
+    for (i=2;i<=length(d);i++)
+    {
+       p[i]=p[i-1]"/"d[i];
+       if (p[i] in fs)
+        { 
+        result1=fs[p[i]];
+        result2=pt[p[i]];
+        }
+    }
+    if (result2 in fs){
+        result=fs[result2]}
+    else{
+        result=result1}
+    print(result);}'
 }
 
 config_editor()
@@ -285,8 +299,9 @@ start_service() {
 	
 	# for overlay data-stk-oo not suppport
 	local cwdfs=$(get_filesystem $workdir)
-	if [ "${cwdfs:0:7}" == "overlay" ]; then
-		echo "fs error ln db to tmp $workdir ${cwdfs:0:7}"
+	echo "workdir is a $cwdfs filesystem"
+	if [ "$cwdfs" == "jffs2" ]; then
+		echo "fs error ln db to tmp $workdir $cwdfs"
 		logger "AdGuardHome" "warning db redirect to tmp"
 		touch $workdir/data/stats.db
 		if [ ! -L $workdir/data/stats.db ]; then