diff --git a/adguardhome/Makefile b/adguardhome/Makefile index 9cfbac054..e805ba96c 100644 --- a/adguardhome/Makefile +++ b/adguardhome/Makefile @@ -50,11 +50,6 @@ define Package/adguardhome/conffiles /etc/adguardhome.yaml endef -define Package/adguardhome/postinst -#!/bin/sh - /etc/init.d/AdGuardHome restart -endef - define Package/adguardhome/description Free and open source, powerful network-wide ads and trackers blocking DNS server. endef diff --git a/luci-app-bypass/Makefile b/luci-app-bypass/Makefile index f84fd011f..b396302fd 100644 --- a/luci-app-bypass/Makefile +++ b/luci-app-bypass/Makefile @@ -24,7 +24,7 @@ PKG_CONFIG_DEPENDS:= \ LUCI_TITLE:=SS/SSR/Xray/Trojan/Trojan-Go/NaiveProxy/Socks5/Tun LuCI interface LUCI_PKGARCH:=all -LUCI_DEPENDS:=+ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +smartdns-le +coreutils +coreutils-base64 +curl +tcping +chinadns-ng +lua +luci-compat +unzip +lua-maxminddb \ +LUCI_DEPENDS:=+ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +smartdns +coreutils +coreutils-base64 +curl +tcping +chinadns-ng +lua +luci-compat +unzip +lua-maxminddb \ +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Server:shadowsocks-libev-ss-server \ +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Client:shadowsocks-libev-ss-local \ +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Libev_Client:shadowsocks-libev-ss-redir \ diff --git a/luci-app-bypass/luasrc/controller/bypass.lua b/luci-app-bypass/luasrc/controller/bypass.lua index 872b1ce44..2ba7f4bfc 100644 --- a/luci-app-bypass/luasrc/controller/bypass.lua +++ b/luci-app-bypass/luasrc/controller/bypass.lua @@ -228,7 +228,7 @@ end function status() local e = {} - e.dns_mode_status = luci.sys.call("pidof smartdns-le >/dev/null") == 0 + e.dns_mode_status = luci.sys.call("pidof smartdns >/dev/null") == 0 e.socks5_status = luci.sys.call("ps -w | grep by- | grep socks5 | grep -v grep >/dev/null") == 0 e.tcp_node_status = luci.sys.call("ps -w | grep by-retcp | grep -v grep >/dev/null") == 0 e.udp_node_status = luci.sys.call("ps -w | grep by-reudp | grep -v grep >/dev/null") == 0 diff --git a/luci-app-bypass/root/etc/hotplug.d/iface/21-bypass b/luci-app-bypass/root/etc/hotplug.d/iface/21-bypass index 43e15c012..1fd444c80 100755 --- a/luci-app-bypass/root/etc/hotplug.d/iface/21-bypass +++ b/luci-app-bypass/root/etc/hotplug.d/iface/21-bypass @@ -7,9 +7,9 @@ if [ "$ACTION" = ifup -a "$INTERFACE" != wan_6 ];then ipset -! add bypass_all $i done fi - if pidof smartdns-le >/dev/null;then - killall -q -9 smartdns-le - $(which smartdns-le) -c /var/etc/smartdns/smartdns.conf + if pidof smartdns >/dev/null;then + killall -q -9 smartdns + $(which smartdns) -c /var/etc/smartdns/smartdns.conf fi fi fi diff --git a/luci-app-bypass/root/etc/init.d/bypass b/luci-app-bypass/root/etc/init.d/bypass index 4fc08de72..9cc655073 100755 --- a/luci-app-bypass/root/etc/init.d/bypass +++ b/luci-app-bypass/root/etc/init.d/bypass @@ -169,7 +169,7 @@ gen_config_file(){ } start_dns(){ - $(which smartdns-le) -c $DNS_T + $(which smartdns) -c $DNS_T case $dns_mode_o in doh) doh_o_a=$(echo $doh_o_a | sed 's/ -http-host dns.google//g') @@ -856,7 +856,7 @@ gen_dns(){ rm -f $O [ $(find $DNS_DIR -name \* -exec cat {} \; 2>/dev/null | wc -l) = 0 ] && rm -rf $DNS_DIR || echo conf-dir=$DNS_DIR >>$DNS_FILE [ $run_mode = router ] && chinadns_flag=1 - killall -q -9 smartdns-le + killall -q -9 smartdns start_dns /etc/init.d/dnsmasq restart >/dev/null 2>&1 preload @@ -1031,7 +1031,7 @@ stop(){ kill -9 $(ps -w | grep by-monitor | grep -v grep | awk '{print$1}') 2>/dev/null kill -9 $(ps -w | grep by-preload | grep -v grep | awk '{print$1}') 2>/dev/null kill -9 $(ps -w | grep $VAR | grep -v grep | awk '{print$1}') 2>/dev/null - killall -q -9 smartdns-le chinadns-ng kcptun-client microsocks + killall -q -9 smartdns chinadns-ng kcptun-client microsocks if [[ $adguardhome == 1 && ! "$GLOBAL_SERVER" ]]; then if [[ -f /etc/init.d/AdGuardHome && "$(uci -q get AdGuardHome.AdGuardHome.redirect)" == "exchange" ]]; then redirect="$(uci -q get AdGuardHome.AdGuardHome.old_redirect)" @@ -1083,9 +1083,9 @@ stop(){ dns_d_l=$(echo $dns_d_l | sed -e 's/,/,/g' -e 's/。/./g' -e 's/:/:/g' -e 's/,/\n/g') for i in $dns_d_l;do echo "server $i" >> $DNS_T;done fi - $(which smartdns-le) -c $DNS_T + $(which smartdns) -c $DNS_T r=1 - while ! ps -w | grep smartdns-le | grep -v grep >/dev/null;do + while ! ps -w | grep smartdns | grep -v grep >/dev/null;do [ $r -ge 10 ] && return 1 || let r++ sleep 1 done diff --git a/luci-app-bypass/root/usr/share/bypass/by-monitor b/luci-app-bypass/root/usr/share/bypass/by-monitor index e892078f9..b002386f4 100755 --- a/luci-app-bypass/root/usr/share/bypass/by-monitor +++ b/luci-app-bypass/root/usr/share/bypass/by-monitor @@ -74,11 +74,11 @@ while :;do fi #smartdns if [ $smartdns = 1 ];then - t=`ps -w | grep smartdns-le | grep -v grep | wc -l` + t=`ps -w | grep smartdns | grep -v grep | wc -l` if [ $t = 0 ];then echolog "SmartDNS Error. Restart!" - killall -q -9 smartdns-le - $(which smartdns-le) -c /var/etc/smartdns/smartdns.conf + killall -q -9 smartdns + $(which smartdns) -c /var/etc/smartdns/smartdns.conf fi fi #chinadns-ng diff --git a/luci-app-godproxy/rulesupdate.log b/luci-app-godproxy/rulesupdate.log index d7834a6c5..00f7a21b2 100644 --- a/luci-app-godproxy/rulesupdate.log +++ b/luci-app-godproxy/rulesupdate.log @@ -1,50 +1,31 @@ -2021-11-16 05:51:24: ------------------- 规则更新 ----------------------- -2021-11-16 05:51:24: ==================================================== -2021-11-16 05:51:24: 开始更新koolproxy的规则,请等待... -2021-11-16 05:51:24: --------------------------------------------------------------------------------------- -2021-11-16 05:51:25: --------------------------------------------------------------------------------------- -2021-11-16 05:51:26: --------------------------------------------------------------------------------------- -2021-11-16 05:51:27: ABP规则的本地版本号: 202111160515 -2021-11-16 05:51:27: ABP规则的在线版本号: 202111160535 -2021-11-16 05:51:27: 检测到 ABP规则 已更新,现在开始更新... -2021-11-16 05:51:27: 将临时的ABP规则文件移动到指定位置 -2021-11-16 05:51:29: Yhosts规则本地版本号: 202111082343 -2021-11-16 05:51:29: Yhosts规则在线版本号: 202111082343 -2021-11-16 05:51:29: 检测到Yhosts本地版本号和在线版本号相同,那还更新个毛啊! -2021-11-16 05:51:30: Fanboy规则本地版本号: -2021-11-16 05:51:30: Fanboy规则在线版本号: 202111160550 -2021-11-16 05:51:30: 检测到新版本 Fanboy规则 列表,开始更新... -2021-11-16 05:51:30: 将临时文件覆盖到原始 Fanboy规则 文件 -2021-11-16 05:51:31: Antiad规则本地版本号: 20211115105634 -2021-11-16 05:51:31: Antiad规则在线版本号: 20211115105634 -2021-11-16 05:51:31: 检测到 Antiad规则 本地版本号和在线版本号相同,那还更新个毛啊! -2021-11-16 05:51:31: Banben规则本地版本号: 20211115115330 -2021-11-16 05:51:31: Banben规则在线版本号: 20211115115330 -2021-11-16 05:51:31: 检测到 Banben手机规则 本地版本号和在线版本号相同,那还更新个毛啊! -2021-11-16 05:51:31: StevenBlack规则本地版本号: 14 November 2021 -2021-11-16 05:51:31: StevenBlack规则在线版本号: 14 November 2021 -2021-11-16 05:51:31: 检测到 StevenBlack规则 本地版本号和在线版本号相同,那还更新个毛啊! -2021-11-16 05:51:31: AdAway规则本地版本号: mobile ad -2021-11-16 05:51:31: AdAway规则在线版本号: -2021-11-16 05:51:31: 检测到新版本 AdAway规则 列表,开始更新... -2021-11-16 05:51:31: 将临时文件覆盖到原始 AdAway规则 文件 -2021-11-16 05:51:31: 正在优化 Fanboy规则。。。。。 -2021-11-16 05:51:32: 正在优化 ABP规则。。。。。 -2021-11-16 05:51:39: 跳过优化 补充规则Yhosts。。。。。 -2021-11-16 05:51:39: 跳过优化 补充规则Antiad。。。。。 -2021-11-16 05:51:39: 跳过优化 补充规则Banben。。。。。 -2021-11-16 05:51:39: 跳过优化 补充规则StevenBlack。。。。。 -2021-11-16 05:51:39: 正在优化 补充规则Adwars。。。。。 -2021-11-16 05:51:39: 正在优化 补充规则AdAway。。。。。 -2021-11-16 05:51:39: 所有规则更新并优化完毕! -2021-11-16 05:51:39: ==================================================== -2021-11-16 05:51:40: -------------------ABP规则 version 202111160535 -2021-11-16 05:51:40: -------------------Fanboy规则 version 202111160550 -2021-11-16 05:51:40: -------------------Yhosts规则 version 202111082343 -2021-11-16 05:51:40: -------------------Antiad规则 version 20211115105634 -2021-11-16 05:51:40: -------------------Banben手机规则 version 20211115115330 -2021-11-16 05:51:40: -------------------StevenBlack规则 version 14 November 2021 -2021-11-16 05:51:40: -------------------静态规则 version 2021-10-07 18:00 -2021-11-16 05:51:40: -------------------乘风视频 version 202111131 -2021-11-16 05:51:40: ------------------- 内置规则更新成功! ------------------- -2021-11-16 05:51:40: ------------------- 规则更新成功! ------------------- +2021-11-16 23:20:28: ------------------- 规则更新 ----------------------- +2021-11-16 23:20:28: ==================================================== +2021-11-16 23:20:28: 开始更新koolproxy的规则,请等待... +2021-11-16 23:20:28: --------------------------------------------------------------------------------------- +2021-11-16 23:20:28: ABP规则本地版本号: +2021-11-16 23:20:28: ABP规则在线版本号: Tue 11/16/2021 +2021-11-16 23:20:28: 检测到新版本 ABP规则 列表,开始更新... +2021-11-16 23:20:28: 将临时文件覆盖到原始 ABP规则 文件 +2021-11-16 23:20:28: --------------------------------------------------------------------------------------- +2021-11-16 23:20:28: Fanboy规则本地版本号: Tue 11/16/2021 +2021-11-16 23:20:28: Fanboy规则在线版本号: Tue 11/16/2021 +2021-11-16 23:20:28: 检测到 Fanboy规则 本地版本号和在线版本号相同,那还更新个毛啊! +2021-11-16 23:20:30: Yhosts规则本地版本号: 202111082343 +2021-11-16 23:20:30: Yhosts规则在线版本号: 202111082343 +2021-11-16 23:20:30: 检测到Yhosts本地版本号和在线版本号相同,那还更新个毛啊! +2021-11-16 23:20:30: Antiad规则本地版本号: 20211117023854 +2021-11-16 23:20:30: Antiad规则在线版本号: 20211117023854 +2021-11-16 23:20:30: 检测到 Antiad规则 本地版本号和在线版本号相同,那还更新个毛啊! +2021-11-16 23:20:30: 正在优化 ABP规则。。。。。 +2021-11-16 23:20:43: 跳过优化 Fanboy规则。。。。。 +2021-11-16 23:20:43: 跳过优化 补充规则Yhosts。。。。。 +2021-11-16 23:20:43: 跳过优化 补充规则Antiad。。。。。 +2021-11-16 23:20:43: 所有规则更新并优化完毕! +2021-11-16 23:20:43: ==================================================== +2021-11-16 23:20:45: -------------------ABP规则 version +2021-11-16 23:20:45: -------------------Fanboy规则 version Tue 11/16/2021 +2021-11-16 23:20:45: -------------------Yhosts规则 version 202111082343 +2021-11-16 23:20:45: -------------------Antiad规则 version 20211117023854 +2021-11-16 23:20:45: -------------------静态规则 version 2021-10-07 18:00 +2021-11-16 23:20:45: ------------------- 内置规则更新成功! ------------------- +2021-11-16 23:20:45: ------------------- 规则更新成功! ------------------- diff --git a/luci-app-gpsysupgrade/Makefile b/luci-app-gpsysupgrade/Makefile index 3a60f8c4d..8c6425319 100644 --- a/luci-app-gpsysupgrade/Makefile +++ b/luci-app-gpsysupgrade/Makefile @@ -1,11 +1,11 @@ -# This is free software, licensed under the Apache License, Version 2.0 . - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=LuCI for sysupgrade -LUCI_DEPENDS:=+luci-base -PKG_MAINTAINER:=Kiddin' - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature +# This is free software, licensed under the Apache License, Version 2.0 . + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI for sysupgrade +LUCI_DEPENDS:=+luci-base +PKG_MAINTAINER:=Kiddin' + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-gpsysupgrade/README.md b/luci-app-gpsysupgrade/README.md index c47bf1f8b..7b6209f04 100644 --- a/luci-app-gpsysupgrade/README.md +++ b/luci-app-gpsysupgrade/README.md @@ -1 +1 @@ -# Only for my Openwrt firmware +# Only for my Openwrt firmware diff --git a/luci-app-gpsysupgrade/luasrc/controller/gpsysupgrade.lua b/luci-app-gpsysupgrade/luasrc/controller/gpsysupgrade.lua index 0e3107ca7..cf96e5737 100644 --- a/luci-app-gpsysupgrade/luasrc/controller/gpsysupgrade.lua +++ b/luci-app-gpsysupgrade/luasrc/controller/gpsysupgrade.lua @@ -1,38 +1,38 @@ --- Copyright (C) 2018-2020 L-WRT Team -module("luci.controller.gpsysupgrade", package.seeall) -local appname = "gpsysupgrade" -local ucic = luci.model.uci.cursor() -local http = require "luci.http" -local util = require "luci.util" -local sysupgrade = require "luci.model.cbi.gpsysupgrade.sysupgrade" - -function index() - appname = "gpsysupgrade" - entry({"admin", "services", appname}).dependent = true - entry({"admin", "services", appname}, template("gpsysupgrade/system_version"), _("System upgrade"), 1) - entry({"admin", "services", appname, "sysversion_check"}, call("sysversion_check")).leaf = true - entry({"admin", "services", appname, "sysversion_update"}, call("sysversion_update")).leaf = true -end - -local function http_write_json(content) - http.prepare_content("application/json") - http.write_json(content or {code = 1}) -end - - -function sysversion_check() - local json = sysupgrade.to_check("") - http_write_json(json) -end - -function sysversion_update() - local json = nil - local task = http.formvalue("task") - if task == "flash" then - json = sysupgrade.to_flash(http.formvalue("file"),http.formvalue("retain")) - else - json = sysupgrade.to_download(http.formvalue("url"),http.formvalue("md5")) - end - - http_write_json(json) -end +-- Copyright (C) 2018-2020 L-WRT Team +module("luci.controller.gpsysupgrade", package.seeall) +local appname = "gpsysupgrade" +local ucic = luci.model.uci.cursor() +local http = require "luci.http" +local util = require "luci.util" +local sysupgrade = require "luci.model.cbi.gpsysupgrade.sysupgrade" + +function index() + appname = "gpsysupgrade" + entry({"admin", "services", appname}).dependent = true + entry({"admin", "services", appname}, template("gpsysupgrade/system_version"), _("System upgrade"), 1) + entry({"admin", "services", appname, "sysversion_check"}, call("sysversion_check")).leaf = true + entry({"admin", "services", appname, "sysversion_update"}, call("sysversion_update")).leaf = true +end + +local function http_write_json(content) + http.prepare_content("application/json") + http.write_json(content or {code = 1}) +end + + +function sysversion_check() + local json = sysupgrade.to_check("") + http_write_json(json) +end + +function sysversion_update() + local json = nil + local task = http.formvalue("task") + if task == "flash" then + json = sysupgrade.to_flash(http.formvalue("file"),http.formvalue("retain")) + else + json = sysupgrade.to_download(http.formvalue("url"),http.formvalue("md5")) + end + + http_write_json(json) +end diff --git a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/api.lua b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/api.lua index bd425799c..a38451c34 100644 --- a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/api.lua +++ b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/api.lua @@ -1,78 +1,78 @@ -module("luci.model.cbi.gpsysupgrade.api", package.seeall) -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require"luci.model.uci".cursor() -local util = require "luci.util" - -appname = "gpsysupgrade" -curl = "/usr/bin/curl" -curl_args = {"-skfL", "--connect-timeout 3", "--retry 3"} -wget = "/usr/bin/wget" -wget_args = {"--no-check-certificate", "--quiet", "--timeout=100", "--tries=3"} -command_timeout = 40 -LEDE_BOARD = nil -DISTRIB_TARGET = nil - -function _unpack(t, i) - i = i or 1 - if t[i] ~= nil then return t[i], _unpack(t, i + 1) end -end - -function exec(cmd, args, writer, timeout) - local os = require "os" - local nixio = require "nixio" - - local fdi, fdo = nixio.pipe() - local pid = nixio.fork() - - if pid > 0 then - fdo:close() - - if writer or timeout then - local starttime = os.time() - while true do - if timeout and os.difftime(os.time(), starttime) >= timeout then - nixio.kill(pid, nixio.const.SIGTERM) - return 1 - end - - if writer then - local buffer = fdi:read(2048) - if buffer and #buffer > 0 then - writer(buffer) - end - end - - local wpid, stat, code = nixio.waitpid(pid, "nohang") - - if wpid and stat == "exited" then return code end - - if not writer and timeout then nixio.nanosleep(1) end - end - else - local wpid, stat, code = nixio.waitpid(pid) - return wpid and stat == "exited" and code - end - elseif pid == 0 then - nixio.dup(fdo, nixio.stdout) - fdi:close() - fdo:close() - nixio.exece(cmd, args, nil) - nixio.stdout:close() - os.exit(1) - end -end - -function auto_get_model() - local arch = nixio.uname().machine or "" - if fs.access("/etc/openwrt_release") then - if arch == "x86_64" then - model = "x86_64" - else - local boardinfo = luci.util.ubus("system", "board") or { } - model = boardinfo.model - end - end - return util.trim(model) -end - +module("luci.model.cbi.gpsysupgrade.api", package.seeall) +local fs = require "nixio.fs" +local sys = require "luci.sys" +local uci = require"luci.model.uci".cursor() +local util = require "luci.util" + +appname = "gpsysupgrade" +curl = "/usr/bin/curl" +curl_args = {"-skfL", "--connect-timeout 3", "--retry 3"} +wget = "/usr/bin/wget" +wget_args = {"--no-check-certificate", "--quiet", "--timeout=100", "--tries=3"} +command_timeout = 40 +LEDE_BOARD = nil +DISTRIB_TARGET = nil + +function _unpack(t, i) + i = i or 1 + if t[i] ~= nil then return t[i], _unpack(t, i + 1) end +end + +function exec(cmd, args, writer, timeout) + local os = require "os" + local nixio = require "nixio" + + local fdi, fdo = nixio.pipe() + local pid = nixio.fork() + + if pid > 0 then + fdo:close() + + if writer or timeout then + local starttime = os.time() + while true do + if timeout and os.difftime(os.time(), starttime) >= timeout then + nixio.kill(pid, nixio.const.SIGTERM) + return 1 + end + + if writer then + local buffer = fdi:read(2048) + if buffer and #buffer > 0 then + writer(buffer) + end + end + + local wpid, stat, code = nixio.waitpid(pid, "nohang") + + if wpid and stat == "exited" then return code end + + if not writer and timeout then nixio.nanosleep(1) end + end + else + local wpid, stat, code = nixio.waitpid(pid) + return wpid and stat == "exited" and code + end + elseif pid == 0 then + nixio.dup(fdo, nixio.stdout) + fdi:close() + fdo:close() + nixio.exece(cmd, args, nil) + nixio.stdout:close() + os.exit(1) + end +end + +function auto_get_model() + local arch = nixio.uname().machine or "" + if fs.access("/etc/openwrt_release") then + if arch == "x86_64" then + model = "x86_64" + else + local boardinfo = luci.util.ubus("system", "board") or { } + model = boardinfo.model + end + end + return util.trim(model) +end + diff --git a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua index 809fa4693..efd8c8adf 100644 --- a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua +++ b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua @@ -1,136 +1,136 @@ -module("luci.model.cbi.gpsysupgrade.sysupgrade", package.seeall) -local fs = require "nixio.fs" -local sys = require "luci.sys" -local util = require "luci.util" -local i18n = require "luci.i18n" -local ipkg = require("luci.model.ipkg") -local api = require "luci.model.cbi.gpsysupgrade.api" - -function get_system_version() - local system_version = luci.sys.exec("[ -f '/etc/openwrt_version' ] && echo -n `cat /etc/openwrt_version`") - return system_version -end - -function check_update() - needs_update, notice, md5 = false, false, false - remote_version = luci.sys.exec("curl -skfL https://op.supes.top/firmware/" ..model.. "/version.txt") - updatelogs = luci.sys.exec("curl -skfL https://op.supes.top/firmware/" ..model.. "/updatelogs.txt") - remoteformat = luci.sys.exec("date -d $(echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $1}' | awk -F. '{printf $3\"-\"$1\"-\"$2}') +%s") - fnotice = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $(NF-1)}'") - dateyr = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F. '{printf $1\".\"$2}'") - md5 = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $2}'") - remote_version = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $1}' | awk -F. '{printf $1\".\"$2\".\"$3}'") - if remoteformat > sysverformat then - needs_update = true - if currentTimeStamp > remoteformat or fnotice == "1" then - notice = true - end - end -end - -function to_check() - if not model or model == "" then model = api.auto_get_model() end - sysverformat = luci.sys.exec("date -d $(echo " ..get_system_version().. " | awk -F. '{printf $3\"-\"$1\"-\"$2}') +%s") - currentTimeStamp = luci.sys.exec("expr $(date -d \"$(date '+%Y-%m-%d %H:%M:%S')\" +%s) - 172800") - if model == "x86_64" then - check_update() - if fs.access("/sys/firmware/efi") then - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-x86-64-generic-squashfs-combined-efi.img.gz" - else - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-x86-64-generic-squashfs-combined.img.gz" - md5 = "" - end - elseif model:match(".*R2S.*") then - model = "nanopi-r2s" - check_update() - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r2s-squashfs-sysupgrade.img.gz" - elseif model:match(".*R4S.*") then - model = "nanopi-r4s" - check_update() - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r4s-squashfs-sysupgrade.img.gz" - elseif model:match(".*R2C.*") then - model = "nanopi-r2c" - check_update() - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r2c-squashfs-sysupgrade.img.gz" - elseif model:match(".*Pi 4 Model B.*") then - model = "Rpi-4B" - check_update() - download_url = "https://op.supes.top/firmware/" ..model.. "/" ..dateyr.. "-openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz" - else - local needs_update = false - return { - code = 1, - error = i18n.translate("Can't determine MODEL, or MODEL not supported.") - } - end - - - if needs_update and not download_url then - return { - code = 1, - now_version = get_system_version(), - version = remote_version, - error = i18n.translate( - "New version found, but failed to get new version download url.") - } - end - - return { - code = 0, - update = needs_update, - notice = notice, - now_version = get_system_version(), - version = remote_version, - md5 = md5, - logs = updatelogs, - url = download_url - } -end - -function to_download(url,md5) - if not url or url == "" then - return {code = 1, error = i18n.translate("Download url is required.")} - end - - sys.call("/bin/rm -f /tmp/firmware_download.*") - - local tmp_file = util.trim(util.exec("mktemp -u -t firmware_download.XXXXXX")) - - local result = api.exec(api.curl, {api._unpack(api.curl_args), "-o", tmp_file, url}, nil, api.command_timeout) == 0 - - if not result then - api.exec("/bin/rm", {"-f", tmp_file}) - return { - code = 1, - error = i18n.translatef("File download failed or timed out: %s", url) - } - end - - local md5local = sys.exec("echo -n $(md5sum " .. tmp_file .. " | awk '{print $1}')") - - if md5 ~= "" and md5local ~= md5 then - api.exec("/bin/rm", {"-f", tmp_file}) - return { - code = 1, - error = i18n.translatef("Md5 check failed: %s", url) - } - end - - return {code = 0, file = tmp_file} -end - -function to_flash(file,retain) - if not file or file == "" or not fs.access(file) then - return {code = 1, error = i18n.translate("Firmware file is required.")} - end -if not retain or retain == "" then - local result = api.exec("/sbin/sysupgrade", {file}, nil, api.command_timeout) == 0 -else - if retain:match(".*-q .*") then - luci.sys.exec("echo -e /etc/backup/user_installed.opkg>/lib/upgrade/keep.d/luci-app-gpsysupgrade") - end - sys.exec("/sbin/sysupgrade " ..retain.. " " ..file.. "") -end - - return {code = 0} -end +module("luci.model.cbi.gpsysupgrade.sysupgrade", package.seeall) +local fs = require "nixio.fs" +local sys = require "luci.sys" +local util = require "luci.util" +local i18n = require "luci.i18n" +local ipkg = require("luci.model.ipkg") +local api = require "luci.model.cbi.gpsysupgrade.api" + +function get_system_version() + local system_version = luci.sys.exec("[ -f '/etc/openwrt_version' ] && echo -n `cat /etc/openwrt_version`") + return system_version +end + +function check_update() + needs_update, notice, md5 = false, false, false + remote_version = luci.sys.exec("curl -skfL https://op.dllkids.xyz/firmware/" ..model.. "/version.txt") + updatelogs = luci.sys.exec("curl -skfL https://op.dllkids.xyz/firmware/" ..model.. "/updatelogs.txt") + remoteformat = luci.sys.exec("date -d $(echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $1}' | awk -F. '{printf $3\"-\"$1\"-\"$2}') +%s") + fnotice = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $(NF-1)}'") + dateyr = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F. '{printf $1\".\"$2}'") + md5 = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $2}'") + remote_version = luci.sys.exec("echo \"" ..remote_version.. "\" | tr '\r\n' ',' | awk -F, '{printf $1}' | awk -F. '{printf $1\".\"$2\".\"$3}'") + if remoteformat > sysverformat then + needs_update = true + if currentTimeStamp > remoteformat or fnotice == "1" then + notice = true + end + end +end + +function to_check() + if not model or model == "" then model = api.auto_get_model() end + sysverformat = luci.sys.exec("date -d $(echo " ..get_system_version().. " | awk -F. '{printf $3\"-\"$1\"-\"$2}') +%s") + currentTimeStamp = luci.sys.exec("expr $(date -d \"$(date '+%Y-%m-%d %H:%M:%S')\" +%s) - 172800") + if model == "x86_64" then + check_update() + if fs.access("/sys/firmware/efi") then + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-x86-64-generic-squashfs-combined-efi.img.gz" + else + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-x86-64-generic-squashfs-combined.img.gz" + md5 = "" + end + elseif model:match(".*R2S.*") then + model = "nanopi-r2s" + check_update() + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r2s-squashfs-sysupgrade.img.gz" + elseif model:match(".*R4S.*") then + model = "nanopi-r4s" + check_update() + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r4s-squashfs-sysupgrade.img.gz" + elseif model:match(".*R2C.*") then + model = "nanopi-r2c" + check_update() + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-rockchip-armv8-nanopi-r2c-squashfs-sysupgrade.img.gz" + elseif model:match(".*Pi 4 Model B.*") then + model = "Rpi-4B" + check_update() + download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..dateyr.. "-openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz" + else + local needs_update = false + return { + code = 1, + error = i18n.translate("Can't determine MODEL, or MODEL not supported.") + } + end + + + if needs_update and not download_url then + return { + code = 1, + now_version = get_system_version(), + version = remote_version, + error = i18n.translate( + "New version found, but failed to get new version download url.") + } + end + + return { + code = 0, + update = needs_update, + notice = notice, + now_version = get_system_version(), + version = remote_version, + md5 = md5, + logs = updatelogs, + url = download_url + } +end + +function to_download(url,md5) + if not url or url == "" then + return {code = 1, error = i18n.translate("Download url is required.")} + end + + sys.call("/bin/rm -f /tmp/firmware_download.*") + + local tmp_file = util.trim(util.exec("mktemp -u -t firmware_download.XXXXXX")) + + local result = api.exec(api.curl, {api._unpack(api.curl_args), "-o", tmp_file, url}, nil, api.command_timeout) == 0 + + if not result then + api.exec("/bin/rm", {"-f", tmp_file}) + return { + code = 1, + error = i18n.translatef("File download failed or timed out: %s", url) + } + end + + local md5local = sys.exec("echo -n $(md5sum " .. tmp_file .. " | awk '{print $1}')") + + if md5 ~= "" and md5local ~= md5 then + api.exec("/bin/rm", {"-f", tmp_file}) + return { + code = 1, + error = i18n.translatef("Md5 check failed: %s", url) + } + end + + return {code = 0, file = tmp_file} +end + +function to_flash(file,retain) + if not file or file == "" or not fs.access(file) then + return {code = 1, error = i18n.translate("Firmware file is required.")} + end +if not retain or retain == "" then + local result = api.exec("/sbin/sysupgrade", {file}, nil, api.command_timeout) == 0 +else + if retain:match(".*-q .*") then + luci.sys.exec("echo -e /etc/backup/user_installed.opkg>/lib/upgrade/keep.d/luci-app-gpsysupgrade") + end + sys.exec("/sbin/sysupgrade " ..retain.. " " ..file.. "") +end + + return {code = 0} +end diff --git a/luci-app-gpsysupgrade/luasrc/view/admin_status/index/links.htm b/luci-app-gpsysupgrade/luasrc/view/admin_status/index/links.htm index db00f33a6..5bbaecef1 100644 --- a/luci-app-gpsysupgrade/luasrc/view/admin_status/index/links.htm +++ b/luci-app-gpsysupgrade/luasrc/view/admin_status/index/links.htm @@ -1,8 +1,8 @@ - + diff --git a/luci-app-gpsysupgrade/luasrc/view/admin_status/index/sysupgrade.htm b/luci-app-gpsysupgrade/luasrc/view/admin_status/index/sysupgrade.htm index 4251a1e04..f17b90a03 100644 --- a/luci-app-gpsysupgrade/luasrc/view/admin_status/index/sysupgrade.htm +++ b/luci-app-gpsysupgrade/luasrc/view/admin_status/index/sysupgrade.htm @@ -1,40 +1,40 @@ -<% -local fs = require "nixio.fs" -local uci = require 'luci.model.uci'.cursor() - -if fs.access('/etc/config/system') then - autoupgrade_fm = uci:get_first('system', 'system', 'autoupgrade_fm', '1') -end -if autoupgrade_fm ~= '0' then --%> - -<% end -%> +<% +local fs = require "nixio.fs" +local uci = require 'luci.model.uci'.cursor() + +if fs.access('/etc/config/system') then + autoupgrade_fm = uci:get_first('system', 'system', 'autoupgrade_fm', '1') +end +if autoupgrade_fm ~= '0' then +-%> + +<% end -%> diff --git a/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm b/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm index 0e4204aef..3f6a7fa03 100644 --- a/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm +++ b/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm @@ -1,241 +1,241 @@ -<% -local system_version = require "luci.model.cbi.gpsysupgrade.sysupgrade".get_system_version() --%> -<%+header%> -