Browse Source

useless del

rufengsuixing 6 years ago
parent
commit
a22020aad0
2 changed files with 26 additions and 13 deletions
  1. 1 1
      luasrc/controller/AdGuardHome.lua
  2. 25 12
      root/usr/share/AdGuardHome/update_core.sh

+ 1 - 1
luasrc/controller/AdGuardHome.lua

@@ -20,7 +20,7 @@ function act_status()
   luci.http.write_json(e)
 end
 function do_update()
-luci.sys.exec("sh /usr/share/AdGuardHome/update_core.sh &")
+luci.sys.exec("(touch /var/run/update_core ; sh /usr/share/AdGuardHome/update_core.sh ;rm /var/run/update_core) &")
 luci.http.prepare_content("application/json")
 luci.http.write('')
 end

+ 25 - 12
root/usr/share/AdGuardHome/update_core.sh

@@ -1,6 +1,5 @@
 #!/bin/bash
 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-touch /var/run/update_core
 binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
 if [ -z "$binpath" ]; then
 uci get AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
@@ -16,7 +15,7 @@ mkdir -p ${configpath%/*}
 
 check_if_already_running(){
 	running_tasks="$(ps |grep "AdGuardHome" |grep "update_core" |grep -v "grep" |awk '{print $1}' |wc -l)"
-	[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." >>/tmp/AdGuardHome_update.log && rm /var/run/update_core && exit 2
+	[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." >>/tmp/AdGuardHome_update.log && exit 2
 }
 
 clean_log(){
@@ -41,7 +40,6 @@ check_latest_version(){
 			echo -e "\nLocal version: ${now_ver}, cloud version: ${latest_ver}." >>/tmp/AdGuardHome_update.log
 			echo -e "You're already using the latest version." >>/tmp/AdGuardHome_update.log
 			uci set AdGuardHome.AdGuardHome.version="${latest_ver}"
-			rm /var/run/update_core
 			exit 3
 	fi
 }
@@ -55,37 +53,55 @@ doupdate_core(){
 	"i386")
 	Arch="386"
 	;;
+	"i686")
+	Arch="386"
+	;;
 	"x86")
 	Arch="amd64"
 	;;
 	"mipsel")
 	Arch="mipsle"
 	;;
+	"mips64el")
+	Arch="mips64le"
+	Arch="mipsle"
+	echo -e "mips64el use $Arch may have bug" >>/tmp/AdGuardHome_update.log
+	;;
 	"mips")
 	Arch="mips"
 	;;
+	"mips64")
+	Arch="mips64"
+	Arch="mips"
+	echo -e "mips64 use $Arch may have bug" >>/tmp/AdGuardHome_update.log
+	;;
 	"arm")
 	Arch="arm"
 	;;
-	"ram64")
-	Arch="arm64"
-	;;
 	"aarch64")
 	Arch="arm64"
 	;;
+	"powerpc")
+	Arch="ppc"
+	echo -e "error not support $Archt" >>/tmp/AdGuardHome_update.log
+	exit 1
+	;;
+	"powerpc64")
+	Arch="ppc64"
+	echo -e "error not support $Archt" >>/tmp/AdGuardHome_update.log
+	exit 1
+	;;
 	*)
 	echo -e "error not support $Archt" >>/tmp/AdGuardHome_update.log
-	rm /var/run/update_core
+	
 	exit 1
 	;;
 	esac
 	wget-ssl --no-check-certificate -t 1 -T 10 -O  /tmp/AdGuardHome/update/AdGuardHome_linux_${Arch}.tar.gz "https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz"  >/dev/null 2>&1
 	tar -zxf "/tmp/AdGuardHome/update/AdGuardHome_linux_${Arch}.tar.gz" -C "/tmp/AdGuardHome/update/" >/dev/null 2>&1
-	
 	if [ ! -e "/tmp/AdGuardHome/update/AdGuardHome" ]; then
 		echo -e "Failed to download core." >>/tmp/AdGuardHome_update.log
 		rm -rf "/tmp/AdGuardHome/update" >/dev/null 2>&1
-		rm /var/run/update_core
 		exit 1
 	else
 		if [ "$(uci get AdGuardHome.AdGuardHome.lessspace)"x != "1"x ]; then
@@ -98,7 +114,6 @@ doupdate_core(){
 					uci set AdGuardHome.AdGuardHome.lessspace="1"
 				else
 					echo "cp failed" >>/tmp/AdGuardHome_update.log
-					rm /var/run/update_core
 					exit 1
 				fi
 			fi
@@ -107,7 +122,6 @@ doupdate_core(){
 			cp -f /tmp/AdGuardHome/update/AdGuardHome/AdGuardHome "$binpath"
 			if [ "$?" != "0" ]; then
 				echo "cp failed" >>/tmp/AdGuardHome_update.log
-				rm /var/run/update_core
 				exit 1
 			fi
 		fi
@@ -118,7 +132,6 @@ doupdate_core(){
 	echo -e "Succeeded in updating core." >>/tmp/AdGuardHome_update.log
 	uci set AdGuardHome.AdGuardHome.version="${latest_ver}"
 	echo -e "Local version: ${now_ver}, cloud version: ${latest_ver}.\n" >>/tmp/AdGuardHome_update.log
-	rm /var/run/update_core
 }
 
 main(){