Browse Source

More compression method (#4)

* add compression method

* fix buton size
rufengsuixing 5 years ago
parent
commit
a42c9c6536

+ 1 - 1
Makefile

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

+ 12 - 6
luasrc/model/cbi/AdGuardHome/base.lua

@@ -11,9 +11,9 @@ local binpath=uci:get("AdGuardHome","AdGuardHome","binpath")
 if (binpath==nil) then
 binpath="/usr/bin/AdGuardHome/AdGuardHome"
 end
-local httpport=luci.sys.exec("awk '/bind_port:/{printf($2);exit;}' "..configpath.." 2>nul")
+local httpport=luci.sys.exec("awk '/bind_port:/{printf($2);exit;}' "..configpath.." 2>/dev/null")
 if (httpport=="") then
-httpport=uci:get("AdGuardHome","AdGuardHome","httpport")
+httpport=uci:get("AdGuardHome","AdGuardHome","httpport") or "3000"
 end
 mp = Map("AdGuardHome", "AdGuard Home")
 mp.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
@@ -26,13 +26,13 @@ s.addremove=false
 o = s:option(Flag, "enabled", translate("Enable adblock"))
 o.default = 0
 o.rmempty = false
----- httport
+---- httpport
 o =s:option(Value,"httpport",translate("Browser management port"))
 o.placeholder=3000
 o.default=3000
 o.datatype="port"
 o.rmempty=false
-o.description = translate("<input type=\"button\" style=\"width:180px;border-color:Teal; text-align:center;font-weight:bold;color:Green;\" value=\"AdGuardHome Web:"..httpport.."\" onclick=\"window.open('http://'+window.location.hostname+':"..httpport.."/')\"/>")
+o.description = translate("<input type=\"button\" style=\"width:210px;border-color:Teal; text-align:center;font-weight:bold;color:Green;\" value=\"AdGuardHome Web:"..httpport.."\" onclick=\"window.open('http://'+window.location.hostname+':"..httpport.."/')\"/>")
 ---- update warning not safe
 version=uci:get("AdGuardHome","AdGuardHome","version")
 e=""
@@ -71,8 +71,14 @@ o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin
 o.default     = "/usr/bin/AdGuardHome/AdGuardHome"
 o.datatype    = "string"
 --- upx
-o = s:option(Flag, "upx", translate("use upx to compress bin after download"))
-o.default = 0
+o = s:option(ListValue, "upxflag", translate("use upx to compress bin after download"))
+o:value("", translate("none"))
+o:value("-1", translate("compress faster"))
+o:value("-9", translate("compress better"))
+o:value("--best", translate("compress best(can be slow for big files)"))
+o:value("--brute", translate("try all available compression methods & filters [slow]"))
+o:value("--ultra-brute", translate("try even more compression variants [very slow]"))
+o.default     = ""
 o.description=translate("bin use less space,but may have compatibility issues")
 ---- config path
 o = s:option(Value, "configpath", translate("Config Path"), translate("AdGuardHome config path"))

+ 15 - 0
po/zh-cn/AdGuardHome.po

@@ -46,6 +46,21 @@ msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载"
 msgid "use upx to compress bin after download"
 msgstr "下载后使用upx压缩执行文件"
 
+msgid "compress faster"
+msgstr "快速压缩"
+
+msgid "compress better"
+msgstr "更好的压缩"
+
+msgid "compress best(can be slow for big files)"
+msgstr "最好的压缩(大文件可能慢)"
+
+msgid "try all available compression methods & filters [slow]"
+msgstr "尝试所有可能的压缩方法和过滤器[慢]"
+
+msgid "try even more compression variants [very slow]"
+msgstr "尝试更多变体压缩手段[很慢]"
+
 msgid "bin use less space,but may have compatibility issues"
 msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
 

+ 1 - 0
root/etc/config/AdGuardHome

@@ -7,4 +7,5 @@ config AdGuardHome 'AdGuardHome'
 	option logfile '/tmp/AdGuardHome.log'
 	option verbose '0'
 	option binpath '/usr/bin/AdGuardHome/AdGuardHome'
+	option upxflag ''
 

+ 5 - 5
root/usr/share/AdGuardHome/update_core.sh

@@ -12,7 +12,7 @@ uci get AdGuardHome.AdGuardHome.configpath="/etc/AdGuardHome.yaml"
 configpath="/etc/AdGuardHome.yaml"
 fi
 mkdir -p ${configpath%/*}
-upx=$(uci get AdGuardHome.AdGuardHome.upx)
+upxflag=$(uci get AdGuardHome.AdGuardHome.upxflag)
 
 check_if_already_running(){
 	running_tasks="$(ps |grep "AdGuardHome" |grep "update_core" |grep -v "grep" |awk '{print $1}' |wc -l)"
@@ -51,14 +51,14 @@ check_latest_version(){
 			echo -e "You're already using the latest version." 
 			uci set AdGuardHome.AdGuardHome.version="${latest_ver}"
 			uci commit AdGuardHome
-			if [ "$upx"x == "1"x ]; then 
+			if [ ! -z "$upxflag" ]; then
 				filesize=$(ls -l $binpath | awk '{ print $5 }')
 				if [ $filesize -gt 8000000 ]; then
 					echo -e "start upx may take a long time"
 					doupx
 					mkdir -p "/tmp/AdGuardHome/update/AdGuardHome" >/dev/null 2>&1
 					rm -fr /tmp/AdGuardHome/update/AdGuardHome/${binpath##*/}
-					/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx -9 $binpath -o /tmp/AdGuardHome/update/AdGuardHome/${binpath##*/}
+					/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $binpath -o /tmp/AdGuardHome/update/AdGuardHome/${binpath##*/}
 					rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
 					/etc/init.d/AdGuardHome stop
 					rm $binpath
@@ -189,11 +189,11 @@ doupdate_core(){
 		exit 1
 	else 
 		echo -e "download success start copy" 
-		if [ "$upx"x == "1"x ]; then
+		if [ ! -z "$upxflag" ]; then
 		echo -e "start upx may take a long time" 
 		doupx
         #maybe need chmod
-		/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx -9  /tmp/AdGuardHome/update/AdGuardHome/AdGuardHome
+		/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag /tmp/AdGuardHome/update/AdGuardHome/AdGuardHome
 		rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
 		fi
 		echo -e "start copy"