update-12.01
This commit is contained in:
parent
65e2d5e836
commit
426f1ac2c6
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
# Only for my <a href="https://github.com/garypang13/OpenWrt/">Openwrt firmware</a>
|
||||
# Only for my <a href="https://github.com/garypang13/OpenWrt/">Openwrt firmware</a>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = {"--quiet", "--connect-timeout=3", "--timeout=6", "--tries=2"}
|
||||
command_timeout = 60
|
||||
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
|
||||
|
||||
|
|
|
@ -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.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
|
||||
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.wget, {api._unpack(api.wget_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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script>
|
||||
setTimeout(function(){
|
||||
var links = document.createElement('div');
|
||||
links.innerHTML ='<div class="table"><div class="tr"><div class="td left" width="33%"><a href="https://t.me/joinchat/JjxmyRZZXJWb74I-sCrryA" target="_blank">TG交流</a></div><div class="td left" width="33%"><a href="https://github.com/kenzok78/Bulid_Wrt" target="_blank">GitHub仓库</a></div><div class="td left"><a href="http://op.dllkids.xyz/" target="_blank">固件下载</a></div></div></div>';
|
||||
var telegram = document.querySelectorAll(".cbi-section")[0];
|
||||
telegram.appendChild(links);
|
||||
}, 2000);
|
||||
</script>
|
||||
<script>
|
||||
setTimeout(function(){
|
||||
var links = document.createElement('div');
|
||||
links.innerHTML ='<div class="table"><div class="tr"><div class="td left" width="33%"><a href="https://t.me/joinchat/JjxmyRZZXJWb74I-sCrryA" target="_blank">TG交流</a></div><div class="td left" width="33%"><a href="https://github.com/kenzok78/Bulid_Wrt" target="_blank">GitHub仓库</a></div><div class="td left"><a href="http://op.dllkids.xyz/" target="_blank">固件下载</a></div></div></div>';
|
||||
var telegram = document.querySelectorAll(".cbi-section")[0];
|
||||
telegram.appendChild(links);
|
||||
}, 2000);
|
||||
</script>
|
||||
|
|
|
@ -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
|
||||
-%>
|
||||
<script>
|
||||
var tokenStr = '<%=token%>';
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_check]])%>', {
|
||||
token: tokenStr,
|
||||
model: ''
|
||||
}, function(x,json) {
|
||||
if(json.code) {
|
||||
|
||||
} else {
|
||||
if(json.notice) {
|
||||
sysUpgradeInfo = json;
|
||||
setTimeout(function(){
|
||||
var ckeckDetailElm = document.querySelector("#maincontent");
|
||||
if(ckeckDetailElm) {
|
||||
var urlNode = '';
|
||||
if(json.version) {
|
||||
urlNode = '<div class="alert-message fade-in success" style="display:flex;margin-top: -1.5rem;padding: 0.31rem 0rem;"><div style="flex:10"><a href="<%=url([[admin]], [[services]], [[gpsysupgrade]])%>"><p><%:New version available%>:' + json.version + '</p></a></div></div>';
|
||||
ckeckDetailElm.innerHTML=urlNode+ckeckDetailElm.innerHTML;
|
||||
}
|
||||
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
},300);
|
||||
|
||||
</script>
|
||||
<% end -%>
|
||||
<%
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require 'luci.model.uci'.cursor()
|
||||
|
||||
if fs.access('/etc/config/wizard') then
|
||||
autoupgrade_fm = uci:get('wizard', 'default', 'autoupgrade_fm')
|
||||
end
|
||||
if autoupgrade_fm ~= '0' then
|
||||
-%>
|
||||
<script>
|
||||
var tokenStr = '<%=token%>';
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_check]])%>', {
|
||||
token: tokenStr,
|
||||
model: ''
|
||||
}, function(x,json) {
|
||||
if(json.code) {
|
||||
|
||||
} else {
|
||||
if(json.notice) {
|
||||
sysUpgradeInfo = json;
|
||||
setTimeout(function(){
|
||||
var ckeckDetailElm = document.querySelector("#maincontent");
|
||||
if(ckeckDetailElm) {
|
||||
var urlNode = '';
|
||||
if(json.version) {
|
||||
urlNode = '<div class="alert-message fade-in success" style="display:flex;margin-top: -1.5rem;padding: 0.31rem 0rem;"><div style="flex:10"><a href="<%=url([[admin]], [[services]], [[gpsysupgrade]])%>"><p><%:New version available%>:' + json.version + '</p></a></div></div>';
|
||||
ckeckDetailElm.innerHTML=urlNode+ckeckDetailElm.innerHTML;
|
||||
}
|
||||
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
},300);
|
||||
|
||||
</script>
|
||||
<% end -%>
|
||||
|
|
|
@ -1,241 +1,241 @@
|
|||
<%
|
||||
local system_version = require "luci.model.cbi.gpsysupgrade.sysupgrade".get_system_version()
|
||||
-%>
|
||||
<%+header%>
|
||||
<h2 name="content"><%:System upgrade%></h2>
|
||||
<%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
|
||||
<p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
|
||||
<%- end -%>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var sysUpgradeInfo;
|
||||
var tokenStr = '<%=token%>';
|
||||
var clickToForceUpdateText = '<%:It is the latest version,Reflash?%>';
|
||||
var updateSuccessText = '<%:Upgrade successful%>';
|
||||
var clickToUpdateText = '<%:Click to Upgrade%>';
|
||||
var inProgressText = '<%:Upgrading...%>';
|
||||
var unexpectedErrorText = '<%:Unexpected error%>';
|
||||
var updateInProgressNotice = '<%:Upgrading, are you sure to close?%>';
|
||||
var downloadingText = '<%:Downloading...%>';
|
||||
var flashing = '<%:Flashing...%>';
|
||||
var checking = '<%:Checking...%>';
|
||||
|
||||
window.onload = function() {
|
||||
var sysupCheckBtn = document.getElementById('_sysup-check_btn');
|
||||
checkUpdate_sysup(sysupCheckBtn)
|
||||
};
|
||||
|
||||
function addPageNotice_sysup() {
|
||||
window.onbeforeunload = function(e) {
|
||||
e.returnValue = updateInProgressNotice;
|
||||
return updateInProgressNotice;
|
||||
};
|
||||
}
|
||||
|
||||
function removePageNotice_sysup() {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
|
||||
function onUpdateSuccess_sysup(btn) {
|
||||
alert(updateSuccessText);
|
||||
|
||||
if(btn) {
|
||||
btn.value = updateSuccessText;
|
||||
btn.placeholder = updateSuccessText;
|
||||
btn.disabled = true;
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function onRequestError_sysup(btn, errorMessage) {
|
||||
btn.disabled = false;
|
||||
btn.value = btn.placeholder;
|
||||
|
||||
if(errorMessage) {
|
||||
alert(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function onBtnClick_sysup(btn) {
|
||||
if(sysUpgradeInfo === undefined) {
|
||||
checkUpdate_sysup(btn);
|
||||
} else {
|
||||
doUpdate_sysup(btn);
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdate_sysup(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = checking;
|
||||
|
||||
addPageNotice_sysup();
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
var updateLogs = document.getElementById('updatelogs');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_check]])%>', {
|
||||
token: tokenStr,
|
||||
model: ''
|
||||
}, function(x,json) {
|
||||
removePageNotice_sysup();
|
||||
|
||||
if(json.code) {
|
||||
sysUpgradeInfo = undefined;
|
||||
onRequestError_sysup(btn, json.error);
|
||||
} else {
|
||||
document.querySelector('#retain').style.display = '';
|
||||
if(json.update) {
|
||||
sysUpgradeInfo = json;
|
||||
btn.disabled = false;
|
||||
btn.value = clickToUpdateText;
|
||||
btn.placeholder = clickToUpdateText;
|
||||
|
||||
if(ckeckDetailElm) {
|
||||
var urlNode = '';
|
||||
if(json.version) {
|
||||
if(json.notice) {
|
||||
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' 正式版</em>';
|
||||
} else {
|
||||
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' 尝鲜版</em>';
|
||||
}
|
||||
}
|
||||
if(json.logs) {
|
||||
logs = '<div class="alert alert-message">' + json.logs + '</div>';
|
||||
}
|
||||
ckeckDetailElm.innerHTML = urlNode;
|
||||
updateLogs.innerHTML = logs;
|
||||
|
||||
}
|
||||
} else {
|
||||
sysUpgradeInfo = json;
|
||||
btn.disabled = false;
|
||||
btn.value = clickToForceUpdateText;
|
||||
btn.placeholder = clickToForceUpdateText;
|
||||
}
|
||||
}
|
||||
},300);
|
||||
}
|
||||
|
||||
function doUpdate_sysup(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = downloadingText;
|
||||
|
||||
addPageNotice_sysup();
|
||||
|
||||
var sysUpgradeUrl = '<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_update]])%>';
|
||||
// Download file
|
||||
XHR.get(sysUpgradeUrl, {
|
||||
token: tokenStr,
|
||||
url: sysUpgradeInfo ? sysUpgradeInfo.url : '',
|
||||
md5: sysUpgradeInfo ? sysUpgradeInfo.md5 : ''
|
||||
}, function(x,json) {
|
||||
if(json.code) {
|
||||
removePageNotice_sysup();
|
||||
onRequestError_sysup(btn, json.error);
|
||||
} else {
|
||||
btn.value = flashing;
|
||||
message.style.display = '';
|
||||
label.innerHTML = '<%:Upgrade successful, Waiting for device...%>';
|
||||
|
||||
var opts = "-u";
|
||||
if (!kconfig.checked){
|
||||
opts = "-n";
|
||||
}
|
||||
|
||||
if (kopkg.checked){
|
||||
opts = "-q -u";
|
||||
}
|
||||
if (!kconfig.checked && kopkg.checked){
|
||||
opts = "-n -q";
|
||||
}
|
||||
removePageNotice_sysup();
|
||||
setTimeout(check, 8000);
|
||||
XHR.get(sysUpgradeUrl, {
|
||||
token: tokenStr,
|
||||
task: 'flash',
|
||||
file: json.file,
|
||||
retain: opts
|
||||
}, function(x,json) {
|
||||
},300)
|
||||
}
|
||||
},300)
|
||||
}
|
||||
//]]>
|
||||
|
||||
</script>
|
||||
|
||||
<div class="cbi-value">
|
||||
<label class="value-title" style="float:left;">
|
||||
<%:Current system version%>
|
||||
</label>
|
||||
|
||||
<div class="cbi-value-description">
|
||||
<span>【 <%=system_version%> 】</span>
|
||||
<span id="_sysup-check_btn-detail"></span>
|
||||
</div>
|
||||
<style>
|
||||
#updatelogs .alert-message p{
|
||||
text-align:left;
|
||||
}
|
||||
#updatelogs .alert-message a{
|
||||
color: orangered;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.red{
|
||||
color: orangered;
|
||||
}
|
||||
#updatelogs h4{
|
||||
padding-bottom:0;
|
||||
}
|
||||
#updatelogs h4.title{
|
||||
font-size:130%
|
||||
}
|
||||
</style>
|
||||
<pre id="updatelogs" style="font-family:Microsoft Yahei;line-height:1.5rem;white-space:pre-line;"></div>
|
||||
<div id="retain" style="display:none;margin:0.5rem;">
|
||||
<p style="margin-top:0.4rem;"><button class="btn"><input type="checkbox" checked id="kconfig"> <%:Keep settings and retain the current configuration%></button></p>
|
||||
<p style="margin-top:0.5rem;"><button class="btn"><input type="checkbox" checked id="kopkg"> <%:Retain the current packages%></button></p>
|
||||
</div>
|
||||
<input class="cbi-button cbi-input-apply cbi-button-reset" type="button" id="_sysup-check_btn" onclick="onBtnClick_sysup(this);" value="<%:Check update%>" style="margin-top:0.5rem;"/>
|
||||
|
||||
</div>
|
||||
<p class="alert-message notice reboot-message" style="display:none">
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
|
||||
<span><%:Device is rebooting...%></span>
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var tries = 0,
|
||||
kconfig = document.querySelector('#kconfig'),
|
||||
kopkg = document.querySelector('#kopkg');
|
||||
var message = document.querySelector('p.reboot-message');
|
||||
var label = message.querySelector('span');
|
||||
|
||||
function ok() {
|
||||
window.location = '<%=url("admin")%>';
|
||||
}
|
||||
|
||||
function check() {
|
||||
window.setTimeout(ping, 3000);
|
||||
}
|
||||
|
||||
function ping() {
|
||||
var img = document.createElement('img');
|
||||
|
||||
img.onload = ok;
|
||||
img.onerror = check;
|
||||
img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
|
||||
|
||||
if (tries++ >= 30) {
|
||||
message.classList.remove('notice');
|
||||
message.classList.add('warning');
|
||||
label.innerHTML = '<%:Device unreachable! Still waiting for device...%>';
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<%+footer%>
|
||||
<%
|
||||
local system_version = require "luci.model.cbi.gpsysupgrade.sysupgrade".get_system_version()
|
||||
-%>
|
||||
<%+header%>
|
||||
<h2 name="content"><%:System upgrade%></h2>
|
||||
<%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
|
||||
<p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
|
||||
<%- end -%>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var sysUpgradeInfo;
|
||||
var tokenStr = '<%=token%>';
|
||||
var clickToForceUpdateText = '<%:It is the latest version,Reflash?%>';
|
||||
var updateSuccessText = '<%:Upgrade successful%>';
|
||||
var clickToUpdateText = '<%:Click to Upgrade%>';
|
||||
var inProgressText = '<%:Upgrading...%>';
|
||||
var unexpectedErrorText = '<%:Unexpected error%>';
|
||||
var updateInProgressNotice = '<%:Upgrading, are you sure to close?%>';
|
||||
var downloadingText = '<%:Downloading...%>';
|
||||
var flashing = '<%:Flashing...%>';
|
||||
var checking = '<%:Checking...%>';
|
||||
|
||||
window.onload = function() {
|
||||
var sysupCheckBtn = document.getElementById('_sysup-check_btn');
|
||||
checkUpdate_sysup(sysupCheckBtn)
|
||||
};
|
||||
|
||||
function addPageNotice_sysup() {
|
||||
window.onbeforeunload = function(e) {
|
||||
e.returnValue = updateInProgressNotice;
|
||||
return updateInProgressNotice;
|
||||
};
|
||||
}
|
||||
|
||||
function removePageNotice_sysup() {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
|
||||
function onUpdateSuccess_sysup(btn) {
|
||||
alert(updateSuccessText);
|
||||
|
||||
if(btn) {
|
||||
btn.value = updateSuccessText;
|
||||
btn.placeholder = updateSuccessText;
|
||||
btn.disabled = true;
|
||||
}
|
||||
|
||||
window.setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function onRequestError_sysup(btn, errorMessage) {
|
||||
btn.disabled = false;
|
||||
btn.value = btn.placeholder;
|
||||
|
||||
if(errorMessage) {
|
||||
alert(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function onBtnClick_sysup(btn) {
|
||||
if(sysUpgradeInfo === undefined) {
|
||||
checkUpdate_sysup(btn);
|
||||
} else {
|
||||
doUpdate_sysup(btn);
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdate_sysup(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = checking;
|
||||
|
||||
addPageNotice_sysup();
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
var updateLogs = document.getElementById('updatelogs');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_check]])%>', {
|
||||
token: tokenStr,
|
||||
model: ''
|
||||
}, function(x,json) {
|
||||
removePageNotice_sysup();
|
||||
|
||||
if(json.code) {
|
||||
sysUpgradeInfo = undefined;
|
||||
onRequestError_sysup(btn, json.error);
|
||||
} else {
|
||||
document.querySelector('#retain').style.display = '';
|
||||
if(json.update) {
|
||||
sysUpgradeInfo = json;
|
||||
btn.disabled = false;
|
||||
btn.value = clickToUpdateText;
|
||||
btn.placeholder = clickToUpdateText;
|
||||
|
||||
if(ckeckDetailElm) {
|
||||
var urlNode = '';
|
||||
if(json.version) {
|
||||
if(json.notice) {
|
||||
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' 正式版</em>';
|
||||
} else {
|
||||
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' 尝鲜版</em>';
|
||||
}
|
||||
}
|
||||
if(json.logs) {
|
||||
logs = '<div class="alert alert-message">' + json.logs + '</div>';
|
||||
}
|
||||
ckeckDetailElm.innerHTML = urlNode;
|
||||
updateLogs.innerHTML = logs;
|
||||
|
||||
}
|
||||
} else {
|
||||
sysUpgradeInfo = json;
|
||||
btn.disabled = false;
|
||||
btn.value = clickToForceUpdateText;
|
||||
btn.placeholder = clickToForceUpdateText;
|
||||
}
|
||||
}
|
||||
},300);
|
||||
}
|
||||
|
||||
function doUpdate_sysup(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = downloadingText;
|
||||
|
||||
addPageNotice_sysup();
|
||||
|
||||
var sysUpgradeUrl = '<%=url([[admin]], [[services]], [[gpsysupgrade]], [[sysversion_update]])%>';
|
||||
// Download file
|
||||
XHR.get(sysUpgradeUrl, {
|
||||
token: tokenStr,
|
||||
url: sysUpgradeInfo ? sysUpgradeInfo.url : '',
|
||||
md5: sysUpgradeInfo ? sysUpgradeInfo.md5 : ''
|
||||
}, function(x,json) {
|
||||
if(json.code) {
|
||||
removePageNotice_sysup();
|
||||
onRequestError_sysup(btn, json.error);
|
||||
} else {
|
||||
btn.value = flashing;
|
||||
message.style.display = '';
|
||||
label.innerHTML = '<%:Upgrade successful, Waiting for device...%>';
|
||||
|
||||
var opts = "-u";
|
||||
if (!kconfig.checked){
|
||||
opts = "-n";
|
||||
}
|
||||
|
||||
if (kopkg.checked){
|
||||
opts = "-q -u";
|
||||
}
|
||||
if (!kconfig.checked && kopkg.checked){
|
||||
opts = "-n -q";
|
||||
}
|
||||
removePageNotice_sysup();
|
||||
setTimeout(check, 8000);
|
||||
XHR.get(sysUpgradeUrl, {
|
||||
token: tokenStr,
|
||||
task: 'flash',
|
||||
file: json.file,
|
||||
retain: opts
|
||||
}, function(x,json) {
|
||||
},300)
|
||||
}
|
||||
},300)
|
||||
}
|
||||
//]]>
|
||||
|
||||
</script>
|
||||
|
||||
<div class="cbi-value">
|
||||
<label class="value-title" style="float:left;">
|
||||
<%:Current system version%>
|
||||
</label>
|
||||
|
||||
<div class="cbi-value-description">
|
||||
<span>【 <%=system_version%> 】</span>
|
||||
<span id="_sysup-check_btn-detail"></span>
|
||||
</div>
|
||||
<style>
|
||||
#updatelogs .alert-message p{
|
||||
text-align:left;
|
||||
}
|
||||
#updatelogs .alert-message a{
|
||||
color: orangered;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.red{
|
||||
color: orangered;
|
||||
}
|
||||
#updatelogs h4{
|
||||
padding-bottom:0;
|
||||
}
|
||||
#updatelogs h4.title{
|
||||
font-size:130%
|
||||
}
|
||||
</style>
|
||||
<pre id="updatelogs" style="font-family:Microsoft Yahei;line-height:1.5rem;white-space:pre-line;"></div>
|
||||
<div id="retain" style="display:none;margin:0.5rem;">
|
||||
<p style="margin-top:0.4rem;"><button class="btn"><input type="checkbox" checked id="kconfig"> <%:Keep settings and retain the current configuration%></button></p>
|
||||
<p style="margin-top:0.5rem;"><button class="btn"><input type="checkbox" checked id="kopkg"> <%:Retain the current packages%></button></p>
|
||||
</div>
|
||||
<input class="cbi-button cbi-input-apply cbi-button-reset" type="button" id="_sysup-check_btn" onclick="onBtnClick_sysup(this);" value="<%:Check update%>" style="margin-top:0.5rem;"/>
|
||||
|
||||
</div>
|
||||
<p class="alert-message notice reboot-message" style="display:none">
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
|
||||
<span><%:Device is rebooting...%></span>
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var tries = 0,
|
||||
kconfig = document.querySelector('#kconfig'),
|
||||
kopkg = document.querySelector('#kopkg');
|
||||
var message = document.querySelector('p.reboot-message');
|
||||
var label = message.querySelector('span');
|
||||
|
||||
function ok() {
|
||||
window.location = '<%=url("admin")%>';
|
||||
}
|
||||
|
||||
function check() {
|
||||
window.setTimeout(ping, 3000);
|
||||
}
|
||||
|
||||
function ping() {
|
||||
var img = document.createElement('img');
|
||||
|
||||
img.onload = ok;
|
||||
img.onerror = check;
|
||||
img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
|
||||
|
||||
if (tries++ >= 30) {
|
||||
message.classList.remove('notice');
|
||||
message.classList.add('warning');
|
||||
label.innerHTML = '<%:Device unreachable! Still waiting for device...%>';
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<%+footer%>
|
||||
|
|
|
@ -50,7 +50,7 @@ msgid "New version found, but failed to get new version download url."
|
|||
msgstr "发现新版本,但未能获得新版本的下载地址。"
|
||||
|
||||
msgid "File download failed or timed out: %s"
|
||||
msgstr "固件下载失败或超时:%s"
|
||||
msgstr "固件下载失败或超时, 请重试. 或下载:%s 到本地, 通过 系统->备份/升级 上传更新."
|
||||
|
||||
msgid "Firmware file required."
|
||||
msgstr "固件文件未找到。"
|
||||
|
|
|
@ -1,101 +1,104 @@
|
|||
#!/bin/sh
|
||||
|
||||
START=99
|
||||
|
||||
LOCK=/var/lock/opkgupgrade.lock
|
||||
BKOPKG="/etc/backup"
|
||||
# 防止重复启动
|
||||
[ -f $LOCK ] && exit 1
|
||||
touch $LOCK
|
||||
|
||||
if [ ! -f "$BKOPKG/user_installed.opkg" ]; then
|
||||
touch /etc/inited
|
||||
fi
|
||||
|
||||
function opkgupgrade() {
|
||||
mkdir -p $BKOPKG
|
||||
if [ ! -f /etc/inited ]; then
|
||||
[ "$(uci -q get dhcp.@dnsmasq[0].noresolv)" ] && {
|
||||
uci -q del dhcp.@dnsmasq[0].noresolv
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq reload
|
||||
}
|
||||
# sh -c "cat '/usr/share/patch/adblock.patch' | patch -d '/' -p1 --forward" >/dev/null 2>&1
|
||||
fi
|
||||
c1=0
|
||||
c2=0
|
||||
c3=0
|
||||
c4=0
|
||||
while ! curl --retry 3 -m 5 https://op.dllkids.xyz >/dev/null 2>&1;do
|
||||
echo "无法连接仓库服务器,请检查网络. $c1" | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log
|
||||
[ $c1 eq 120 ] && return || let c1++
|
||||
sleep 5
|
||||
done
|
||||
while :; do
|
||||
opkg update | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
def="$(opkg list-upgradable | cut -f 1 -d ' ' | grep -vE 'opkg|luci-lib-fs|firewall|base-files|luci-base|busybox|^?nginx($|-)|dnsmasq-full|coremark|miniupnpd|luci-mod-network|luci-mod-status|luci-mod-system')"
|
||||
if [ ! -f /etc/inited ]; then
|
||||
insed="$(cat $BKOPKG/user_installed.opkg)"
|
||||
fi
|
||||
upopkg="$insed $def"
|
||||
if [ "$upopkg" != " " ]; then
|
||||
for ipk in $upopkg; do
|
||||
while [ ! "$(opkg list-installed | cut -f 1 -d ' ' | grep -w $ipk)" ]; do
|
||||
opkg install --force-overwrite --force-checksum --force-depends $ipk 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
[ $c2 eq 3 ] && {
|
||||
echo $ipk >> $BKOPKG/failed.txt
|
||||
sed -i "/^$ipk$/d" $BKOPKG/user_installed.opkg
|
||||
break
|
||||
} || let c2++
|
||||
sleep 1
|
||||
rm -f /var/lock/opkg.lock
|
||||
done
|
||||
if [[ $ipk == luci-app-* ]]; then
|
||||
opkg install --force-overwrite --force-checksum luci-i18n-"$(echo $ipk | cut -d - -f 3-4)"-zh-cn 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
fi
|
||||
done
|
||||
rm -f /etc/config/*-opkg
|
||||
fi
|
||||
while [[ -f $BKOPKG/failed.txt && -f /etc/inited && $c4 -le 5 ]]; do
|
||||
for ipk in $(cat $BKOPKG/failed.txt); do
|
||||
opkg install --force-overwrite --force-checksum --force-depends $ipk 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
[[ "$(opkg list-installed | cut -f 1 -d ' ' | grep -w $ipk)" ]] && {
|
||||
sed -i "/^$ipk$/d" $BKOPKG/failed.txt
|
||||
[ -n "$(cat $BKOPKG/failed.txt)" ] || rm -f $BKOPKG/failed.txt
|
||||
}
|
||||
done
|
||||
let c4++
|
||||
sleep 1
|
||||
rm -f /var/lock/opkg.lock
|
||||
done
|
||||
if [[ $ipk == luci-app-* ]]; then
|
||||
opkg install --force-overwrite --force-checksum luci-i18n-"$(echo $ipk | cut -d - -f 3-4)"-zh-cn 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
fi
|
||||
mv $BKOPKG/failed.txt $BKOPKG/failed_.txt >/dev/null 2>&1
|
||||
touch /etc/inited
|
||||
rm -f /var/lock/opkg.lock
|
||||
break
|
||||
fi
|
||||
[ $c3 eq 10 ] && break || let c3++
|
||||
done
|
||||
rm -f /var/lock/opkg.lock
|
||||
}
|
||||
(
|
||||
if [[ ! -f /etc/inited || -f $BKOPKG/failed.txt ]]; then
|
||||
opkgupgrade || true
|
||||
elif [[ -f /etc/inited && `uci -q get system.@system[0].autoupgrade_pkg || echo "1"` != '0' ]]; then
|
||||
opkgupgrade || true
|
||||
fi
|
||||
rm -f /var/lock/opkg.lock
|
||||
|
||||
[[ -f "/bin/coremark" && ! -f "/etc/bench.log" ]] && {
|
||||
sleep 5
|
||||
/bin/coremark >/tmp/coremark.log
|
||||
cat /tmp/coremark.log | grep "CoreMark 1.0" | cut -d "/" -f 1 >/etc/bench.log
|
||||
sed -i 's/CoreMark 1.0/(CpuMark/g' /etc/bench.log
|
||||
echo " Scores)" >>/etc/bench.log
|
||||
}
|
||||
|
||||
rm -f $LOCK
|
||||
) &
|
||||
#!/bin/sh
|
||||
|
||||
START=99
|
||||
|
||||
LOCK=/var/lock/opkgupgrade.lock
|
||||
BKOPKG="/etc/backup"
|
||||
# 防止重复启动
|
||||
[ -f $LOCK ] && exit 1
|
||||
touch $LOCK
|
||||
|
||||
if [ ! -f "$BKOPKG/user_installed.opkg" ]; then
|
||||
touch /etc/inited
|
||||
fi
|
||||
|
||||
function opkgupgrade() {
|
||||
mkdir -p $BKOPKG
|
||||
if [ ! -f /etc/inited ]; then
|
||||
[ "$(uci -q get dhcp.@dnsmasq[0].noresolv)" ] && {
|
||||
uci -q del dhcp.@dnsmasq[0].noresolv
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq reload
|
||||
}
|
||||
# sh -c "cat '/usr/share/patch/adblock.patch' | patch -d '/' -p1 --forward" >/dev/null 2>&1
|
||||
fi
|
||||
c1=0
|
||||
c2=0
|
||||
c3=0
|
||||
c4=0
|
||||
while ! curl --retry 3 -m 5 https://op.supes.top >/dev/null 2>&1;do
|
||||
echo "无法连接仓库服务器,请检查网络. $c1" | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log
|
||||
[ $c1 -eq 120 ] && return || let c1++
|
||||
sleep 5
|
||||
done
|
||||
while :; do
|
||||
opkg update | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
def="$(opkg list-upgradable | cut -f 1 -d ' ' | grep -vE 'opkg|luci-lib-fs|firewall|base-files|luci-base|busybox|^?nginx($|-)|dnsmasq-full|coremark|miniupnpd|luci-mod-network|luci-mod-status|luci-mod-system')"
|
||||
if [ ! -f /etc/inited ]; then
|
||||
insed="$(cat $BKOPKG/user_installed.opkg)"
|
||||
fi
|
||||
upopkg="$insed $def"
|
||||
if [ "$upopkg" != " " ]; then
|
||||
for ipk in $upopkg; do
|
||||
while :; do
|
||||
opkg install --force-overwrite --force-checksum --force-depends $ipk 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
[[ "$(opkg list-installed | cut -f 1 -d ' ' | grep -w $ipk)" ]] && {
|
||||
break
|
||||
}
|
||||
[ $c2 -eq 3 ] && {
|
||||
echo $ipk >> $BKOPKG/failed.txt
|
||||
sed -i "/^$ipk$/d" $BKOPKG/user_installed.opkg
|
||||
break
|
||||
} || let c2++
|
||||
sleep 1
|
||||
rm -f /var/lock/opkg.lock
|
||||
done
|
||||
if [[ $ipk == luci-app-* ]]; then
|
||||
opkg install --force-overwrite --force-checksum luci-i18n-"$(echo $ipk | cut -d - -f 3-)"-zh-cn 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
fi
|
||||
done
|
||||
rm -f /etc/config/*-opkg
|
||||
fi
|
||||
while [[ -f $BKOPKG/failed.txt && -f /etc/inited && $c4 -le 5 ]]; do
|
||||
for ipk in $(cat $BKOPKG/failed.txt); do
|
||||
opkg install --force-overwrite --force-checksum --force-depends $ipk 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
[[ "$(opkg list-installed | cut -f 1 -d ' ' | grep -w $ipk)" ]] && {
|
||||
sed -i "/^$ipk$/d" $BKOPKG/failed.txt
|
||||
[ -n "$(cat $BKOPKG/failed.txt)" ] || rm -f $BKOPKG/failed.txt
|
||||
}
|
||||
done
|
||||
let c4++
|
||||
sleep 1
|
||||
rm -f /var/lock/opkg.lock
|
||||
done
|
||||
if [[ $ipk == luci-app-* ]]; then
|
||||
opkg install --force-overwrite --force-checksum luci-i18n-"$(echo $ipk | cut -d - -f 3-)"-zh-cn 2>&1 | sed -e "s/^/$(date +%Y-%m-%d" "%H:%M:%S) /" >>/tmp/opkgupdate.log 2>&1 || true
|
||||
fi
|
||||
mv $BKOPKG/failed.txt $BKOPKG/failed_.txt >/dev/null 2>&1
|
||||
touch /etc/inited
|
||||
rm -f /var/lock/opkg.lock
|
||||
break
|
||||
fi
|
||||
[ $c3 -eq 10 ] && break || let c3++
|
||||
done
|
||||
rm -f /var/lock/opkg.lock
|
||||
}
|
||||
(
|
||||
if [[ ! -f /etc/inited || -f $BKOPKG/failed.txt ]]; then
|
||||
opkgupgrade || true
|
||||
elif [[ -f /etc/inited && "$(uci -q get wizard.default.autoupgrade_pkg)" != '0' ]]; then
|
||||
opkgupgrade || true
|
||||
fi
|
||||
rm -f /var/lock/opkg.lock
|
||||
|
||||
[[ -f "/bin/coremark" && ! -f "/etc/bench.log" && "$(uci -q get wizard.default.coremark)" == '1' ]] && {
|
||||
sleep 5
|
||||
/bin/coremark >/tmp/coremark.log
|
||||
cat /tmp/coremark.log | grep "CoreMark 1.0" | cut -d "/" -f 1 | cut -d "." -f -2 >/etc/bench.log
|
||||
sed -i 's/CoreMark 1.0/(CpuMark/g' /etc/bench.log
|
||||
echo " Scores)" >>/etc/bench.log
|
||||
}
|
||||
|
||||
rm -f $LOCK
|
||||
) &
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
chmod +x /etc/init.d/packages >/dev/null 2>&1
|
||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||
chmod +x /etc/init.d/packages >/dev/null 2>&1
|
||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||
|
|
|
@ -57,6 +57,8 @@ define Package/my-autocore-arm/install
|
|||
endef
|
||||
|
||||
define Package/my-autocore-x86/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/autocore
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) ./files/x86/cpuinfo $(1)/sbin/cpuinfo
|
||||
$(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2017 lean <coolsnowwolf@gmail.com>
|
||||
|
||||
START=99
|
||||
|
||||
start()
|
||||
{
|
||||
rfc=4096
|
||||
cc=$(grep -c processor /proc/cpuinfo)
|
||||
rsfe=$(echo $cc*$rfc | bc)
|
||||
sysctl -w net.core.rps_sock_flow_entries=$rsfe >/dev/null
|
||||
for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus)
|
||||
do
|
||||
echo $cc > $fileRps
|
||||
done
|
||||
|
||||
for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt)
|
||||
do
|
||||
echo $rfc > $fileRfc
|
||||
done
|
||||
|
||||
uci set network.@globals[0].packet_steering=1
|
||||
uci commit network
|
||||
|
||||
a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq)
|
||||
b=$(echo -n ' : ')
|
||||
c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l)
|
||||
d=$(echo -n ' Core ')
|
||||
e=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
|
||||
f=$(echo -n ' Thread ')
|
||||
g=${b}${c}${d}${e}${f}
|
||||
|
||||
mkdir -p /tmp/sysinfo
|
||||
sed -i "s/\(.\+\)/\1$g /" /tmp/sysinfo/model
|
||||
|
||||
a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.")
|
||||
b=$(echo "$a" | wc -l)
|
||||
for i in $(seq 1 $b)
|
||||
do
|
||||
c=$(echo "$a" | sed -n ${i}p)
|
||||
ethtool -K $c rx-checksum on >/dev/null 2>&1
|
||||
ethtool -K $c tx-checksum-ip-generic on >/dev/null 2>&1 || (
|
||||
ethtool -K $c tx-checksum-ipv4 on >/dev/null 2>&1
|
||||
ethtool -K $c tx-checksum-ipv6 on >/dev/null 2>&1)
|
||||
ethtool -K $c tx-scatter-gather on >/dev/null 2>&1
|
||||
ethtool -K $c gso on >/dev/null 2>&1
|
||||
ethtool -K $c tso on >/dev/null 2>&1
|
||||
ethtool -K $c ufo on >/dev/null 2>&1
|
||||
done
|
||||
}
|
|
@ -89,7 +89,6 @@ function storage_info()
|
|||
|
||||
# query various systems and send some stuff to the background for overall faster execution.
|
||||
# Works only with ambienttemp and batteryinfo since A20 is slow enough :)
|
||||
ip_address=$(get_ip_addresses &)
|
||||
storage_info
|
||||
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
|
||||
|
||||
|
@ -120,6 +119,17 @@ swap_info=$(LC_ALL=C free -m | grep "^Swap")
|
|||
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
|
||||
swap_total=$(awk '{print $(2)}' <<<${swap_info})
|
||||
|
||||
[ ! -f /etc/config/network ] && {
|
||||
printf " System initializing please wait..."
|
||||
echo ""
|
||||
echo ""
|
||||
}
|
||||
c=0
|
||||
while [ ! -f /etc/config/network ];do
|
||||
[ $c -eq 8 ] && break || let c++
|
||||
sleep 1
|
||||
done
|
||||
ip_address="$(get_ip_addresses)"
|
||||
|
||||
# display info
|
||||
display "系统负载" "${load%% *}" "${critical_load}" "0" "" "${load#* }"
|
||||
|
@ -132,20 +142,11 @@ display "交换内存" "$swap_usage" "10" "0" " %" " of $swap_total""Mb"
|
|||
printf "IP 地址: \x1B[92m%s\x1B[0m" "$ip_address"
|
||||
echo "" # fixed newline
|
||||
|
||||
|
||||
a=0;b=0;c=0
|
||||
display "CPU 温度" "$board_temp" "45" "0" "°C" "" ; a=$?
|
||||
display "环境温度" "$amb_temp" "40" "0" "°C" "" ; b=$?
|
||||
(( ($a+$b) >0 )) && echo "" # new line only if some value is displayed
|
||||
|
||||
|
||||
display "启动存储" "$boot_usage" "90" "1" "%" " of $boot_total"
|
||||
display "系统存储" "$root_usage" "90" "1" "%" " of $root_total"
|
||||
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(/sbin/cpuinfo)"
|
||||
echo ""
|
||||
|
||||
display "数据存储" "$data_usage" "90" "1" "%" " of $data_total"
|
||||
display "媒体存储" "$media_usage" "90" "1" "%" " of $media_total"
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
|
||||
|
|
|
@ -158,12 +158,3 @@ msgstr "客户端缓存的最小 DNS TTL"
|
|||
|
||||
msgid "Modify DNS entries minimum TTL (max is 86400, 0 is no modify)"
|
||||
msgstr "修改发送到客户端的域名记录的 TTL 时间 (最大 86400, 0 表示不修改)"
|
||||
|
||||
msgid "Firmware Settings"
|
||||
msgstr "固件设置"
|
||||
|
||||
msgid "Packages Auto Upgrade"
|
||||
msgstr "软件包自动更新"
|
||||
|
||||
msgid "Firmware Upgrade Notice"
|
||||
msgstr "固件更新提醒"
|
||||
|
|
Loading…
Reference in New Issue