update 03-13 16:53

This commit is contained in:
github-actions[bot] 2022-03-13 16:53:19 +08:00
parent a9ca08237f
commit 80514e539f
44 changed files with 2781 additions and 2782 deletions

View File

@ -27,7 +27,6 @@ define Package/luci-app-adguardhome/conffiles
/usr/share/AdGuardHome/links.txt
/etc/config/AdGuardHome
/etc/AdGuardHome.yaml
/etc/AdGuardHome.yaml
endef
define Package/luci-app-adguardhome/postinst

22
luci-app-gpsysupgrade/Makefile Normal file → Executable file
View File

@ -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

2
luci-app-gpsysupgrade/README.md Normal file → Executable file
View File

@ -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>

View File

@ -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

View File

@ -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 = {"--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
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

View File

@ -1,127 +1,127 @@
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 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)}'")
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.. "/" ..remote_version.. "-openwrt-x86-64-generic-squashfs-combined-efi.img.gz"
else
download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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
sys.call("/sbin/sysupgrade " ..retain.. " " ..file.. "")
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 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)}'")
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.. "/" ..remote_version.. "-openwrt-x86-64-generic-squashfs-combined-efi.img.gz"
else
download_url = "https://op.dllkids.xyz/firmware/" ..model.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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.. "/" ..remote_version.. "-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
sys.call("/sbin/sysupgrade " ..retain.. " " ..file.. "")
return {code = 0}
end

View File

@ -1,42 +1,42 @@
<%
local fs = require "nixio.fs"
local uci = require 'luci.model.uci'.cursor()
luci.sys.exec("opkg update >/dev/null &")
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 -%>
<%
local fs = require "nixio.fs"
local uci = require 'luci.model.uci'.cursor()
luci.sys.exec("opkg update >/dev/null &")
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 -%>

View File

@ -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 + ' &nbsp;正式版</em>';
} else {
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' &nbsp;尝鲜版</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 = "-k -u";
}
if (!kconfig.checked && kopkg.checked){
opts = "-n -k";
}
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>
&nbsp;&nbsp;&nbsp;<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 + ' &nbsp;正式版</em>';
} else {
urlNode = '<em style="color:red;">最新版本号:' + json.version + ' &nbsp;尝鲜版</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 = "-k -u";
}
if (!kconfig.checked && kopkg.checked){
opts = "-n -k";
}
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>
&nbsp;&nbsp;&nbsp;<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%>

130
luci-app-gpsysupgrade/po/zh_Hans/gpsysupgrade.po Normal file → Executable file
View File

@ -1,65 +1,65 @@
msgid "System upgrade"
msgstr "系统在线更新"
msgid "Upgrade..."
msgstr "更新中"
msgid "Current system version"
msgstr "当前固件版本"
msgid "It is the latest version,Reflash?"
msgstr "已是最新版,重刷此版本?"
msgid "Upgrade successful"
msgstr "更新成功"
msgid "Click to Upgrade"
msgstr "点击更新"
msgid "Upgrading..."
msgstr "更新中"
msgid "Checking..."
msgstr "正在检查更新"
msgid "Flashing..."
msgstr "正在刷入..."
msgid "Check update"
msgstr "检查更新"
msgid "Unexpected error"
msgstr "意外错误"
msgid "Upgrading, are you sure to close?"
msgstr "正在更新,你确认要关闭吗?"
msgid "Downloading..."
msgstr "下载中"
msgid "Unpacking..."
msgstr "解压中"
msgid "Can't determine MODEL, or MODEL not supported."
msgstr "无法确认型号,或是不支持。"
msgid "Get remote version info failed."
msgstr "获取远程版本信息失败。"
msgid "New version found, but failed to get new version download url."
msgstr "发现新版本,但未能获得新版本的下载地址。"
msgid "File download failed or timed out: %s"
msgstr "固件下载失败或超时, 请重试. 或下载:%s 到本地, 通过 系统->备份/升级 上传更新."
msgid "Firmware file required."
msgstr "固件文件未找到。"
msgid "New version available"
msgstr "新版本可用"
msgid "Upgrade successful, Waiting for device..."
msgstr "更新成功, 等待设备重启后响应..."
msgid "Device unreachable! Still waiting for device..."
msgstr "无法连接设备! 继续等待..."
msgid "System upgrade"
msgstr "系统在线更新"
msgid "Upgrade..."
msgstr "更新中"
msgid "Current system version"
msgstr "当前固件版本"
msgid "It is the latest version,Reflash?"
msgstr "已是最新版,重刷此版本?"
msgid "Upgrade successful"
msgstr "更新成功"
msgid "Click to Upgrade"
msgstr "点击更新"
msgid "Upgrading..."
msgstr "更新中"
msgid "Checking..."
msgstr "正在检查更新"
msgid "Flashing..."
msgstr "正在刷入..."
msgid "Check update"
msgstr "检查更新"
msgid "Unexpected error"
msgstr "意外错误"
msgid "Upgrading, are you sure to close?"
msgstr "正在更新,你确认要关闭吗?"
msgid "Downloading..."
msgstr "下载中"
msgid "Unpacking..."
msgstr "解压中"
msgid "Can't determine MODEL, or MODEL not supported."
msgstr "无法确认型号,或是不支持。"
msgid "Get remote version info failed."
msgstr "获取远程版本信息失败。"
msgid "New version found, but failed to get new version download url."
msgstr "发现新版本,但未能获得新版本的下载地址。"
msgid "File download failed or timed out: %s"
msgstr "固件下载失败或超时, 请重试. 或下载:%s 到本地, 通过 系统->备份/升级 上传更新."
msgid "Firmware file required."
msgstr "固件文件未找到。"
msgid "New version available"
msgstr "新版本可用"
msgid "Upgrade successful, Waiting for device..."
msgstr "更新成功, 等待设备重启后响应..."
msgid "Device unreachable! Still waiting for device..."
msgstr "无法连接设备! 继续等待..."

View File

@ -1,18 +1,18 @@
. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_find_wan6 NET_IF6
if [ "${INTERFACE}" != "${NET_IF}" ] \
&& [ "${INTERFACE}" != "${NET_IF6}" ]
then exit 0
fi
if [ "${ACTION}" != "ifup" ] \
&& [ "${ACTION}" != "ifupdate" ]
then exit 0
fi
if [ "${ACTION}" = "ifupdate" ] \
&& [ -z "${IFUPDATE_ADDRESSES}" ] \
&& [ -z "${IFUPDATE_DATA}" ]
then exit 0
fi
hotplug-call online
. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_find_wan6 NET_IF6
if [ "${INTERFACE}" != "${NET_IF}" ] \
&& [ "${INTERFACE}" != "${NET_IF6}" ]
then exit 0
fi
if [ "${ACTION}" != "ifup" ] \
&& [ "${ACTION}" != "ifupdate" ]
then exit 0
fi
if [ "${ACTION}" = "ifupdate" ] \
&& [ -z "${IFUPDATE_ADDRESSES}" ] \
&& [ -z "${IFUPDATE_DATA}" ]
then exit 0
fi
hotplug-call online

View File

@ -1 +1 @@
sleep 3
sleep 3

View File

@ -1,39 +1,39 @@
. /etc/profile.d/opkg.sh
OPKG_PI="$(opkg export pi)"
if [ ! -e /etc/opkg-restore-auto ] \
&& lock -n /var/lock/opkg-restore && [ -s "${OPKG_PI}" ]; then
c=0
while ! curl https://op.supes.top >/dev/null || ! opkg update >/dev/null; do
echo "Network error." | logger -t opkg
[[ "$(uci -q get dhcp.@dnsmasq[0].noresolv)" == 1 && c == 0 ]] && {
uci -q del dhcp.@dnsmasq[0].noresolv
uci commit dhcp
uci -q get network.lan.dns || {
uci -q set network.lan.dns='223.5.5.5'
uci commit network
/etc/init.d/network reload
}
/etc/init.d/dnsmasq reload
}
[ $c -eq 200 ] && {
lock -u /var/lock/opkg-restore
exit 0
} || let c++
sleep 3
done
c1=0
logs="1"
while [ "$logs" != "" ]; do
logs="$(opkg restore)"
echo "${logs}" | logger -t opkg
[ $c1 -eq 5 ] && {
lock -u /var/lock/opkg-restore
exit 0
} || let c1++
sleep 2
done
touch /etc/opkg-restore-auto
fi
lock -u /var/lock/opkg-restore
. /etc/profile.d/opkg.sh
OPKG_PI="$(opkg export pi)"
if [ ! -e /etc/opkg-restore-auto ] \
&& lock -n /var/lock/opkg-restore && [ -s "${OPKG_PI}" ]; then
c=0
while ! curl https://op.dllkids.xyz >/dev/null || ! opkg update >/dev/null; do
echo "Network error." | logger -t opkg
[[ "$(uci -q get dhcp.@dnsmasq[0].noresolv)" == 1 && c == 0 ]] && {
uci -q del dhcp.@dnsmasq[0].noresolv
uci commit dhcp
uci -q get network.lan.dns || {
uci -q set network.lan.dns='223.5.5.5'
uci commit network
/etc/init.d/network reload
}
/etc/init.d/dnsmasq reload
}
[ $c -eq 200 ] && {
lock -u /var/lock/opkg-restore
exit 0
} || let c++
sleep 3
done
c1=0
logs="1"
while [ "$logs" != "" ]; do
logs="$(opkg restore)"
echo "${logs}" | logger -t opkg
[ $c1 -eq 5 ] && {
lock -u /var/lock/opkg-restore
exit 0
} || let c1++
sleep 2
done
touch /etc/opkg-restore-auto
fi
lock -u /var/lock/opkg-restore

View File

@ -1,7 +1,7 @@
if [ "$(uci -q get wizard.default.autoupgrade_pkg)" != '0' ] \
&& lock -n /var/lock/opkg-upgrade && opkg update; then
. /etc/profile.d/opkg.sh
opkg upgr 2>&1 \
| logger -t opkg
fi
lock -u /var/lock/opkg-upgrade
if [ "$(uci -q get wizard.default.autoupgrade_pkg)" != '0' ] \
&& lock -n /var/lock/opkg-upgrade && opkg update; then
. /etc/profile.d/opkg.sh
opkg upgr 2>&1 \
| logger -t opkg
fi
lock -u /var/lock/opkg-upgrade

396
luci-app-gpsysupgrade/root/etc/profile.d/opkg.sh Normal file → Executable file
View File

@ -1,198 +1,198 @@
opkg() {
local OPKG_CMD="${1}"
local OPKG_UCI="$(uci -q get opkg.defaults."${OPKG_CMD}")"
case "${OPKG_CMD}" in
(init|uci|import|save|restore|rollback\
|upgr|export|newconf|proc|reinstall) opkg_"${@}" ;;
(*) command opkg "${@}" ;;
esac
}
opkg_init() {
uci import opkg < /dev/null
uci -q batch << EOI
set opkg.defaults='opkg'
set opkg.defaults.import='/etc/backup/installed_packages.txt'
set opkg.defaults.save='auto'
set opkg.defaults.restore='auto'
set opkg.defaults.rollback='auto'
set opkg.defaults.upgr='ai'
set opkg.defaults.export='ai'
set opkg.defaults.proc='--force-overwrite --force-checksum --force-depends'
set opkg.defaults.reinstall='--force-reinstall --force-overwrite --force-checksum --force-depends'
set opkg.defaults.newconf='/etc'
EOI
echo "kmod busybox base-files luci-app-openclash " \
| sed -e "s/\s/ ipkg\n/g" | opkg uci ignore
}
opkg_uci() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_OPT="${OPKG_OPT:-auto}"
if ! uci -q get opkg > /dev/null
then opkg init
fi
uci -q batch << EOI
delete opkg.'${OPKG_OPT}'
set opkg.'${OPKG_OPT}'='opkg'
$(sed -r -e "s/^(.*)\s(.*)$/\
del_list opkg.'${OPKG_OPT}'.'\2'='\1'\n\
add_list opkg.'${OPKG_OPT}'.'\2'='\1'/")
commit opkg
EOI
}
opkg_import() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
if [ -e "${OPKG_OPT}" ]
then sed -n -r -e "s/\s(overlay|unknown)$/\
\tipkg/p" "${OPKG_OPT}" \
| opkg uci auto
fi
}
opkg_save() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_WR="$(opkg export wr)"
local OPKG_WI="$(opkg export wi)"
local OPKG_UR="$(opkg export ur)"
local OPKG_UI="$(opkg export ui)"
if uci -q get fstab.rwm > /dev/null \
&& grep -q -e "\s/rwm\s" /etc/mtab
then {
sed -e "s/$/\trpkg/" "${OPKG_WR}"
sed -e "s/$/\tipkg/" "${OPKG_WI}"
} | opkg uci init
fi
{
sed -e "s/$/\trpkg/" "${OPKG_UR}"
sed -e "s/$/\tipkg/" "${OPKG_UI}"
} | opkg uci "${OPKG_OPT}"
rm -f "${OPKG_WR}" "${OPKG_WI}" "${OPKG_UR}" "${OPKG_UI}"
}
opkg_restore() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_CONF="${OPKG_OPT}"
local OPKG_AI="$(opkg export ai)"
local OPKG_PR="$(opkg export pr)"
local OPKG_PI="$(opkg export pi)"
grep -x -f "${OPKG_AI}" "${OPKG_PR}" \
| opkg proc remove
grep -v -x -f "${OPKG_AI}" "${OPKG_PI}" \
| opkg proc install
rm -f "${OPKG_AI}" "${OPKG_PR}" "${OPKG_PI}"
}
opkg_rollback() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_CONF="${OPKG_OPT}"
local OPKG_UR="$(opkg export ur)"
local OPKG_UI="$(opkg export ui)"
local OPKG_PR="$(opkg export pr)"
local OPKG_PI="$(opkg export pi)"
if uci -q get opkg."${OPKG_CONF}" > /dev/null
then opkg restore "${OPKG_CONF}"
grep -v -x -f "${OPKG_PI}" "${OPKG_UI}" \
| opkg proc remove
grep -v -x -f "${OPKG_PR}" "${OPKG_UR}" \
| opkg proc install
fi
rm -f "${OPKG_UR}" "${OPKG_UI}" "${OPKG_PR}" "${OPKG_PI}"
}
opkg_upgr() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
case "${OPKG_OPT}" in
(ai|oi) opkg_"${OPKG_CMD}"_type ;;
esac | opkg proc upgrade
}
opkg_upgr_type() {
local OPKG_AI="$(opkg export ai)"
local OPKG_OI="$(opkg export oi)"
local OPKG_AU="$(opkg export au)"
case "${OPKG_OPT::1}" in
(a) grep -x -f "${OPKG_AI}" "${OPKG_AU}" ;;
(o) grep -x -f "${OPKG_OI}" "${OPKG_AU}" ;;
esac
rm -f "${OPKG_AI}" "${OPKG_OI}" "${OPKG_AU}"
}
opkg_export() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_TEMP="$(mktemp -t opkg.XXXXXX)"
case "${OPKG_OPT}" in
(ai|au) opkg_"${OPKG_CMD}"_cmd ;;
(ri|wr|wi|or|oi) opkg_"${OPKG_CMD}"_type ;;
(ur|ui) opkg_"${OPKG_CMD}"_run ;;
(pr|pi|ig) opkg_"${OPKG_CMD}"_uci ;;
esac > "${OPKG_TEMP}"
echo "${OPKG_TEMP}"
}
opkg_export_cmd() {
local OPKG_TYPE
local OPKG_IG="$(opkg export ig)"
case "${OPKG_OPT:1}" in
(i) OPKG_TYPE="installed";opkg list-"${OPKG_TYPE}" | sed -e "s/\s.*$//" ;;
(u) OPKG_TYPE="upgradable";opkg list-"${OPKG_TYPE}" | sed -e "s/\s.*$//" | grep -v -f "${OPKG_IG}" ;;
esac
}
opkg_export_type() {
local OPKG_INFO="/usr/lib/opkg/info"
local OPKG_TYPE
case "${OPKG_OPT::1}" in
(r) OPKG_INFO="/rom${OPKG_INFO}" ;;
(w) OPKG_INFO="/rwm/upper${OPKG_INFO}" ;;
(o) OPKG_INFO="/overlay/upper${OPKG_INFO}" ;;
esac
case "${OPKG_OPT:1}" in
(r) OPKG_TYPE="c" ;;
(i) OPKG_TYPE="f" ;;
esac
find "${OPKG_INFO}" -name "*.control" \
-type "${OPKG_TYPE}" 2> /dev/null \
| sed -e "s/^.*\///;s/\.control$//"
}
opkg_export_run() {
local OPKG_AI="$(opkg export ai)"
local OPKG_RI="$(opkg export ri)"
case "${OPKG_OPT:1}" in
(r) grep -v -x -f "${OPKG_AI}" "${OPKG_RI}" ;;
(i) grep -v -x -f "${OPKG_RI}" "${OPKG_AI}" ;;
esac
rm -f "${OPKG_AI}" "${OPKG_RI}"
}
opkg_export_uci() {
local OPKG_TYPE
case "${OPKG_OPT:1}" in
(r) OPKG_TYPE="rpkg"; OPKG_CONF="auto" ;;
(i) OPKG_TYPE="ipkg"; OPKG_CONF="auto" ;;
(g) OPKG_TYPE="ipkg"; OPKG_CONF="ignore" ;;
esac
uci -q get opkg."${OPKG_CONF}"."${OPKG_TYPE}" \
| sed -e "s/\s/\n/g"
}
opkg_proc() {
local OPKG_OPT="${OPKG_UCI}"
local OPKG_CMD="${1:?}"
local OPKG_PKG
while read -r OPKG_PKG
do opkg "${OPKG_CMD}" "${OPKG_PKG}" ${OPKG_OPT}
done
}
opkg_reinstall() {
local OPKG_OPT="${OPKG_UCI}"
opkg install "${@}" ${OPKG_OPT}
}
opkg_newconf() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
find "${OPKG_OPT}" -name "*-opkg"
}
opkg() {
local OPKG_CMD="${1}"
local OPKG_UCI="$(uci -q get opkg.defaults."${OPKG_CMD}")"
case "${OPKG_CMD}" in
(init|uci|import|save|restore|rollback\
|upgr|export|newconf|proc|reinstall) opkg_"${@}" ;;
(*) command opkg "${@}" ;;
esac
}
opkg_init() {
uci import opkg < /dev/null
uci -q batch << EOI
set opkg.defaults='opkg'
set opkg.defaults.import='/etc/backup/installed_packages.txt'
set opkg.defaults.save='auto'
set opkg.defaults.restore='auto'
set opkg.defaults.rollback='auto'
set opkg.defaults.upgr='ai'
set opkg.defaults.export='ai'
set opkg.defaults.proc='--force-overwrite --force-checksum --force-depends'
set opkg.defaults.reinstall='--force-reinstall --force-overwrite --force-checksum --force-depends'
set opkg.defaults.newconf='/etc'
EOI
echo "kmod busybox base-files luci-app-openclash " \
| sed -e "s/\s/ ipkg\n/g" | opkg uci ignore
}
opkg_uci() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_OPT="${OPKG_OPT:-auto}"
if ! uci -q get opkg > /dev/null
then opkg init
fi
uci -q batch << EOI
delete opkg.'${OPKG_OPT}'
set opkg.'${OPKG_OPT}'='opkg'
$(sed -r -e "s/^(.*)\s(.*)$/\
del_list opkg.'${OPKG_OPT}'.'\2'='\1'\n\
add_list opkg.'${OPKG_OPT}'.'\2'='\1'/")
commit opkg
EOI
}
opkg_import() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
if [ -e "${OPKG_OPT}" ]
then sed -n -r -e "s/\s(overlay|unknown)$/\
\tipkg/p" "${OPKG_OPT}" \
| opkg uci auto
fi
}
opkg_save() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_WR="$(opkg export wr)"
local OPKG_WI="$(opkg export wi)"
local OPKG_UR="$(opkg export ur)"
local OPKG_UI="$(opkg export ui)"
if uci -q get fstab.rwm > /dev/null \
&& grep -q -e "\s/rwm\s" /etc/mtab
then {
sed -e "s/$/\trpkg/" "${OPKG_WR}"
sed -e "s/$/\tipkg/" "${OPKG_WI}"
} | opkg uci init
fi
{
sed -e "s/$/\trpkg/" "${OPKG_UR}"
sed -e "s/$/\tipkg/" "${OPKG_UI}"
} | opkg uci "${OPKG_OPT}"
rm -f "${OPKG_WR}" "${OPKG_WI}" "${OPKG_UR}" "${OPKG_UI}"
}
opkg_restore() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_CONF="${OPKG_OPT}"
local OPKG_AI="$(opkg export ai)"
local OPKG_PR="$(opkg export pr)"
local OPKG_PI="$(opkg export pi)"
grep -x -f "${OPKG_AI}" "${OPKG_PR}" \
| opkg proc remove
grep -v -x -f "${OPKG_AI}" "${OPKG_PI}" \
| opkg proc install
rm -f "${OPKG_AI}" "${OPKG_PR}" "${OPKG_PI}"
}
opkg_rollback() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_CONF="${OPKG_OPT}"
local OPKG_UR="$(opkg export ur)"
local OPKG_UI="$(opkg export ui)"
local OPKG_PR="$(opkg export pr)"
local OPKG_PI="$(opkg export pi)"
if uci -q get opkg."${OPKG_CONF}" > /dev/null
then opkg restore "${OPKG_CONF}"
grep -v -x -f "${OPKG_PI}" "${OPKG_UI}" \
| opkg proc remove
grep -v -x -f "${OPKG_PR}" "${OPKG_UR}" \
| opkg proc install
fi
rm -f "${OPKG_UR}" "${OPKG_UI}" "${OPKG_PR}" "${OPKG_PI}"
}
opkg_upgr() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
case "${OPKG_OPT}" in
(ai|oi) opkg_"${OPKG_CMD}"_type ;;
esac | opkg proc upgrade
}
opkg_upgr_type() {
local OPKG_AI="$(opkg export ai)"
local OPKG_OI="$(opkg export oi)"
local OPKG_AU="$(opkg export au)"
case "${OPKG_OPT::1}" in
(a) grep -x -f "${OPKG_AI}" "${OPKG_AU}" ;;
(o) grep -x -f "${OPKG_OI}" "${OPKG_AU}" ;;
esac
rm -f "${OPKG_AI}" "${OPKG_OI}" "${OPKG_AU}"
}
opkg_export() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_TEMP="$(mktemp -t opkg.XXXXXX)"
case "${OPKG_OPT}" in
(ai|au) opkg_"${OPKG_CMD}"_cmd ;;
(ri|wr|wi|or|oi) opkg_"${OPKG_CMD}"_type ;;
(ur|ui) opkg_"${OPKG_CMD}"_run ;;
(pr|pi|ig) opkg_"${OPKG_CMD}"_uci ;;
esac > "${OPKG_TEMP}"
echo "${OPKG_TEMP}"
}
opkg_export_cmd() {
local OPKG_TYPE
local OPKG_IG="$(opkg export ig)"
case "${OPKG_OPT:1}" in
(i) OPKG_TYPE="installed";opkg list-"${OPKG_TYPE}" | sed -e "s/\s.*$//" ;;
(u) OPKG_TYPE="upgradable";opkg list-"${OPKG_TYPE}" | sed -e "s/\s.*$//" | grep -v -f "${OPKG_IG}" ;;
esac
}
opkg_export_type() {
local OPKG_INFO="/usr/lib/opkg/info"
local OPKG_TYPE
case "${OPKG_OPT::1}" in
(r) OPKG_INFO="/rom${OPKG_INFO}" ;;
(w) OPKG_INFO="/rwm/upper${OPKG_INFO}" ;;
(o) OPKG_INFO="/overlay/upper${OPKG_INFO}" ;;
esac
case "${OPKG_OPT:1}" in
(r) OPKG_TYPE="c" ;;
(i) OPKG_TYPE="f" ;;
esac
find "${OPKG_INFO}" -name "*.control" \
-type "${OPKG_TYPE}" 2> /dev/null \
| sed -e "s/^.*\///;s/\.control$//"
}
opkg_export_run() {
local OPKG_AI="$(opkg export ai)"
local OPKG_RI="$(opkg export ri)"
case "${OPKG_OPT:1}" in
(r) grep -v -x -f "${OPKG_AI}" "${OPKG_RI}" ;;
(i) grep -v -x -f "${OPKG_RI}" "${OPKG_AI}" ;;
esac
rm -f "${OPKG_AI}" "${OPKG_RI}"
}
opkg_export_uci() {
local OPKG_TYPE
case "${OPKG_OPT:1}" in
(r) OPKG_TYPE="rpkg"; OPKG_CONF="auto" ;;
(i) OPKG_TYPE="ipkg"; OPKG_CONF="auto" ;;
(g) OPKG_TYPE="ipkg"; OPKG_CONF="ignore" ;;
esac
uci -q get opkg."${OPKG_CONF}"."${OPKG_TYPE}" \
| sed -e "s/\s/\n/g"
}
opkg_proc() {
local OPKG_OPT="${OPKG_UCI}"
local OPKG_CMD="${1:?}"
local OPKG_PKG
while read -r OPKG_PKG
do opkg "${OPKG_CMD}" "${OPKG_PKG}" ${OPKG_OPT}
done
}
opkg_reinstall() {
local OPKG_OPT="${OPKG_UCI}"
opkg install "${@}" ${OPKG_OPT}
}
opkg_newconf() {
local OPKG_OPT="${1:-${OPKG_UCI}}"
find "${OPKG_OPT}" -name "*-opkg"
}

View File

@ -1,9 +1,9 @@
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
grep -q "opkg-upgrade" /etc/crontabs/root || {
hour="$(grep -m1 -ao '[4-6]' /dev/urandom | head -n1)"
min="$(grep -m1 -ao '[0-5][0-9]' /dev/urandom | head -n1)"
echo "$min $hour * * * . /etc/hotplug.d/online/51-opkg-upgrade" >> /etc/crontabs/root
}
exit 0
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
grep -q "opkg-upgrade" /etc/crontabs/root || {
hour="$(grep -m1 -ao '[4-6]' /dev/urandom | head -n1)"
min="$(grep -m1 -ao '[0-5][0-9]' /dev/urandom | head -n1)"
echo "$min $hour * * * . /etc/hotplug.d/online/51-opkg-upgrade" >> /etc/crontabs/root
}
exit 0

162
my-autocore/Makefile Normal file → Executable file
View File

@ -1,81 +1,81 @@
#
# Copyright (C) 2010-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=my-autocore
PKG_VERSION:=1
PKG_RELEASE:=29
include $(INCLUDE_DIR)/package.mk
define Package/my-autocore-arm
SECTION:=libs
CATEGORY:=Libraries
TITLE:=ARM auto core script.
MAINTAINER:=CN_SZTL
DEPENDS:=@(arm||aarch64) \
+TARGET_bcm27xx:bcm27xx-userland \
+TARGET_bcm53xx:nvram \
+ethtool
VARIANT:=arm
endef
define Package/my-autocore-x86
SECTION:=libs
CATEGORY:=Libraries
TITLE:=x86/x64 auto core loadbalance script.
MAINTAINER:=Lean / CN_SZTL
DEPENDS:=@TARGET_x86 +bc +lm-sensors +ethtool
VARIANT:=x86
endef
define Package/my-autocore-arm/description
Display more details info about the devices in LuCI.
endef
define Download/armcpuinfo
URL:=https://raw.githubusercontent.com/immortalwrt/immortalwrt/master/package/emortal/autocore/files/arm
URL_FILE:=cpuinfo
FILE:=cpuinfo
HASH:=skip
endef
define Build/Prepare
sed -i 's/cpu_arch="?"/cpu_arch="ARMv8 Processor"/' $(DL_DIR)/cpuinfo
endef
define Build/Compile
endef
define Package/my-autocore-arm/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo
$(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/common/29_eth.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
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
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/common/29_eth.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DATA) ./files/x86/nvme_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
endef
$(eval $(call Download,armcpuinfo))
$(eval $(call BuildPackage,my-autocore-arm))
$(eval $(call BuildPackage,my-autocore-x86))
#
# Copyright (C) 2010-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=my-autocore
PKG_VERSION:=1
PKG_RELEASE:=29
include $(INCLUDE_DIR)/package.mk
define Package/my-autocore-arm
SECTION:=libs
CATEGORY:=Libraries
TITLE:=ARM auto core script.
MAINTAINER:=CN_SZTL
DEPENDS:=@(arm||aarch64) \
+TARGET_bcm27xx:bcm27xx-userland \
+TARGET_bcm53xx:nvram \
+ethtool
VARIANT:=arm
endef
define Package/my-autocore-x86
SECTION:=libs
CATEGORY:=Libraries
TITLE:=x86/x64 auto core loadbalance script.
MAINTAINER:=Lean / CN_SZTL
DEPENDS:=@TARGET_x86 +bc +lm-sensors +ethtool
VARIANT:=x86
endef
define Package/my-autocore-arm/description
Display more details info about the devices in LuCI.
endef
define Download/armcpuinfo
URL:=https://raw.githubusercontent.com/immortalwrt/immortalwrt/master/package/emortal/autocore/files/arm
URL_FILE:=cpuinfo
FILE:=cpuinfo
HASH:=skip
endef
define Build/Prepare
sed -i 's/cpu_arch="?"/cpu_arch="ARMv8 Processor"/' $(DL_DIR)/cpuinfo
endef
define Build/Compile
endef
define Package/my-autocore-arm/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo
$(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/common/29_eth.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
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
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/common/29_eth.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DATA) ./files/x86/nvme_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
endef
$(eval $(call Download,armcpuinfo))
$(eval $(call BuildPackage,my-autocore-arm))
$(eval $(call BuildPackage,my-autocore-x86))

68
my-autocore/files/common/29_eth.js Normal file → Executable file
View File

@ -1,34 +1,34 @@
'use strict';
'require rpc';
var callEthInfo = rpc.declare({
object: 'luci',
method: 'getEthInfo'
});
return L.Class.extend({
title: _('Interfaces'),
load: function() {
return L.resolveDefault(callEthInfo(), {});
},
render: function(info) {
if (info && info.result) {
var result = "";
var ports = eval('(' + info.result + ')');
var tmp = "<div class='table' width='100%' cellspacing='10' style='text-align: center' id='ethinfo'><ul style='list-style: none; margin:0 auto; display: inline-block;'>";
for (var i in ports) {
tmp = tmp + String.format(
'<li style="float: left; margin: 0px 1em;"><span style="line-height:25px">%s</span><br /><small><img draggable="false" src="/luci-static/resources/icons/%s" /><br />%s<br />%s</small></li>',
ports[i].name,
ports[i].status ? 'port_up.png' : 'port_down.png',
ports[i].speed,
ports[i].duplex ? _('full-duplex') : _('half-duplex'));
}
tmp + "</ul></div>";
result = tmp;
return result;
}
}
});
'use strict';
'require rpc';
var callEthInfo = rpc.declare({
object: 'luci',
method: 'getEthInfo'
});
return L.Class.extend({
title: _('Interfaces'),
load: function() {
return L.resolveDefault(callEthInfo(), {});
},
render: function(info) {
if (info && info.result) {
var result = "";
var ports = eval('(' + info.result + ')');
var tmp = "<div class='table' width='100%' cellspacing='10' style='text-align: center' id='ethinfo'><ul style='list-style: none; margin:0 auto; display: inline-block;'>";
for (var i in ports) {
tmp = tmp + String.format(
'<li style="float: left; margin: 0px 1em;"><span style="line-height:25px">%s</span><br /><small><img draggable="false" src="/luci-static/resources/icons/%s" /><br />%s<br />%s</small></li>',
ports[i].name,
ports[i].status ? 'port_up.png' : 'port_down.png',
ports[i].speed,
ports[i].duplex ? _('full-duplex') : _('half-duplex'));
}
tmp + "</ul></div>";
result = tmp;
return result;
}
}
});

556
my-autocore/files/common/disc_status.htm Normal file → Executable file
View File

@ -1,278 +1,278 @@
<% local raid = {}
local devs = {}
local devinfo = {}
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "e0c0ff" }
local mounts = nixio.fs.readfile("/proc/mounts")
local show_raid = 1
local show_disc = 1
if self then
if self.hide_raid then
show_raid = 0
end
if self.hide_disc then
show_disc = 0
end
end
function disp_size(s)
local units = { "kB", "MB", "GB", "TB" }
local i, unit
s = s / 2
for i, unit in ipairs(units) do
if (i == #units) or (s < 1024) then
return math.floor(s * 100) / 100 .. unit
end
s = s / 1024
end
end
function first_line(s)
local n = s:find("\n")
if n then
return s:sub(1, n-1)
end
return s
end
function get_fs(pname, status)
for r,raid in ipairs(raid) do
for m,member in ipairs(raid.members) do
if member.name == pname then
return "(raid member)"
end
end
end
local mounted_fs = mounts:match("\n[a-z/]*" .. pname .. " [^ ]* ([^ ]*)")
if mounted_fs then
if status == "standby" then
return "(" .. mounted_fs .. ")"
end
local df = luci.sys.exec("df /dev/" .. pname):match(" ([0-9]+)%% ")
return "(" .. mounted_fs .. " " .. df .. "%)"
end
if status == "standby" then
return
end
local blkid = luci.sys.exec(" blkid -s TYPE /dev/" .. pname):match("TYPE=\"(.*)\"")
if blkid then
return "(" .. blkid .. ")"
end
end
function get_status(raid)
for m,member in ipairs(raid.members) do
for d,dev in ipairs(devinfo) do
if member.name == dev.name then
return dev.status
end
for p,part in ipairs(dev.parts) do
if member.name == part.name then
return dev.status
end
end
end
end
end
function get_parts(dev,status,size)
local c = 1
local unused = size
local parts = {}
for part in nixio.fs.glob("/sys/block/" .. dev .."/" .. dev .. "*") do
local pname = nixio.fs.basename(part)
local psize = nixio.fs.readfile(part .. "/size")
table.insert(parts, {name=pname, size=psize, perc=math.floor(psize*100/size), fs=get_fs(pname,status), color=colors[c]})
c = c + 1
unused = unused - psize
end
if unused > 2048 then
table.insert(parts, { name="", fs=get_fs(dev,status), size=unused, color=colors[c] })
end
return parts
end
for dev in nixio.fs.glob("/sys/block/*") do
if nixio.fs.access(dev .. "/md") then
local name = nixio.fs.basename(dev)
local rlevel = first_line(nixio.fs.readfile(dev .. "/md/level"))
local ndisks = tonumber(nixio.fs.readfile(dev .. "/md/raid_disks"))
local size = tonumber(nixio.fs.readfile(dev .. "/size"))
local metav = nixio.fs.readfile(dev .. "/md/metadata_version")
local degr = tonumber(nixio.fs.readfile(dev .. "/md/degraded"))
local sync = first_line(nixio.fs.readfile(dev .. "/md/sync_action"))
local sync_speed = tonumber(nixio.fs.readfile(dev .. "/md/sync_speed"))
local sync_compl = nixio.fs.readfile(dev .. "/md/sync_completed")
local status = "active"
if sync ~= "idle" then
local progress, total = nixio.fs.readfile(dev .. "/md/sync_completed"):match("^([0-9]*)[^0-9]*([0-9]*)")
local rem = (total - progress) / sync_speed / 2
local rems = math.floor(rem % 60)
if rems < 10 then rems = "0" .. rems end
rem = math.floor(rem / 60)
local remm = math.floor(rem % 60)
if remm < 10 then remm = "0" .. remm end
local remh = math.floor(rem / 60)
local remstr = remh .. ":" .. remm .. ":" .. rems
status = sync .. " (" .. math.floor(sync_speed/1024) .. "MB/s, " .. math.floor(progress * 1000 / total) /10 .. "%, rem. " .. remstr .. ")"
elseif degr == 1 then
status = "degraded"
end
local members = {}
local c = 1
for member in nixio.fs.glob("/sys/block/" .. name .. "/md/dev-*") do
local dname = nixio.fs.basename(nixio.fs.readlink(member .. "/block"))
local dsize = disp_size(tonumber(nixio.fs.readfile(member .. "/block/size")))
local dstate = nixio.fs.readfile(member .. "/state"):gsub("_", " "):match "^%s*(.-)%s*$"
table.insert(members, { name = dname, size = dsize, state = dstate, color = colors[c] })
c = c + 1
end
table.insert(raid, {name=name, rlevel=rlevel, ndisks=ndisks, size=size, metav=metav, status=status, members=members })
end
end
if show_disc == 1 then
for dev in nixio.fs.glob("/sys/class/scsi_disk/*/device") do
local section
local model = nixio.fs.readfile(dev .. "/model")
local fw = nixio.fs.readfile(dev .. "/rev")
for bdev in nixio.fs.glob(dev .. "/block/*") do
local section
local name = nixio.fs.basename(bdev)
local size = tonumber(nixio.fs.readfile(bdev .. "/size"))
local unused = size
local status = "-"
local temp = "-"
local serial = "-"
local secsize = "-"
for _,line in ipairs(luci.util.execl("smartctl -A -i -n standby -f brief /dev/" .. name)) do
local attrib, val
if section == 1 then
attrib, val = line:match "^(.*):%s*(.*)"
elseif section == 2 then
attrib, val = line:match("^([0-9 ]*) [^ ]* * [POSRCK-]* *[0-9-]* *[0-9-]* *[0-9-]* *[0-9-]* *([0-9-]*)")
else
attrib = line:match "^=== START OF (.*) SECTION ==="
if attrib == "INFORMATION" then
section = 1
elseif attrib == "READ SMART DATA" then
section = 2
elseif status == "-" then
val = line:match "^Device is in (.*) mode"
if val then
status = val:lower()
end
end
end
if not attrib then
if section ~= 2 then section = 0 end
elseif (attrib == "Power mode is") or (attrib == "Power mode was") then
status = val:lower():match "(%S*)"
elseif attrib == "Sector Sizes" then
secsize = val:match "([0-9]*) bytes physical"
elseif attrib == "Sector Size" then
secsize = val:match "([0-9]*)"
elseif attrib == "Serial Number" then
serial = val
elseif attrib == "194" then
temp = val .. "&deg;C"
end
end
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, status=status, temp=temp, serial=serial, secsize=secsize, parts=get_parts(name,status,size) })
end
end
for r,dev in ipairs(raid) do
table.insert(devinfo, {name=dev.name, model="Linux RAID", size=dev.size, status=get_status(dev), secsize=secsize, parts=get_parts(dev.name,status,dev.size) })
end
end
if show_disc == 1 then %>
<div class="cbi-section">
<h3><%:Disks%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="15%"><%:Serial number%></th>
<th width="10%"><%:Firmware%></th>
<th width="10%"><%:Capacity%></th>
<th width="5%"><%:Sector size%></th>
<th width="5%"><%:Temperature%></th>
<th width="20%"><%:Power state%></th>
</tr>
<% local style=true
for d,dev in ipairs(devinfo) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.model%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.serial%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.fw%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.secsize%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.temp%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding:0px; border-top-width:0px;" colspan="7" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,part in pairs(dev.parts) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=part.color%>" width="<%=part.perc%>%"><%=part.name%> <%=disp_size(part.size)%> <%=part.fs%></td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end
if show_raid == 1 and #raid > 0 then %>
<div class="cbi-section">
<h3><%:Raid arrays%></h3>
<table class="cbi-section-table" style="white-space:nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="13%"><%:Level%></th>
<th width="13%"><%:# Disks%></th>
<th width="13%"><%:Capacity%></th>
<th width="13%"><%:Metadata%></th>
<th width="43%"><%:Status%></th>
</tr>
<% local style=true
for r,dev in ipairs(raid) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.rlevel%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.ndisks%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.metav%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding-top:0px; border-top-width:0px" colspan="6" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,member in pairs(dev.members) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=member.color%>; white-space: nowrap"><%=member.name%> <%=member.size%> (<%=member.state%>)</td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end %>
<% local raid = {}
local devs = {}
local devinfo = {}
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "e0c0ff" }
local mounts = nixio.fs.readfile("/proc/mounts")
local show_raid = 1
local show_disc = 1
if self then
if self.hide_raid then
show_raid = 0
end
if self.hide_disc then
show_disc = 0
end
end
function disp_size(s)
local units = { "kB", "MB", "GB", "TB" }
local i, unit
s = s / 2
for i, unit in ipairs(units) do
if (i == #units) or (s < 1024) then
return math.floor(s * 100) / 100 .. unit
end
s = s / 1024
end
end
function first_line(s)
local n = s:find("\n")
if n then
return s:sub(1, n-1)
end
return s
end
function get_fs(pname, status)
for r,raid in ipairs(raid) do
for m,member in ipairs(raid.members) do
if member.name == pname then
return "(raid member)"
end
end
end
local mounted_fs = mounts:match("\n[a-z/]*" .. pname .. " [^ ]* ([^ ]*)")
if mounted_fs then
if status == "standby" then
return "(" .. mounted_fs .. ")"
end
local df = luci.sys.exec("df /dev/" .. pname):match(" ([0-9]+)%% ")
return "(" .. mounted_fs .. " " .. df .. "%)"
end
if status == "standby" then
return
end
local blkid = luci.sys.exec(" blkid -s TYPE /dev/" .. pname):match("TYPE=\"(.*)\"")
if blkid then
return "(" .. blkid .. ")"
end
end
function get_status(raid)
for m,member in ipairs(raid.members) do
for d,dev in ipairs(devinfo) do
if member.name == dev.name then
return dev.status
end
for p,part in ipairs(dev.parts) do
if member.name == part.name then
return dev.status
end
end
end
end
end
function get_parts(dev,status,size)
local c = 1
local unused = size
local parts = {}
for part in nixio.fs.glob("/sys/block/" .. dev .."/" .. dev .. "*") do
local pname = nixio.fs.basename(part)
local psize = nixio.fs.readfile(part .. "/size")
table.insert(parts, {name=pname, size=psize, perc=math.floor(psize*100/size), fs=get_fs(pname,status), color=colors[c]})
c = c + 1
unused = unused - psize
end
if unused > 2048 then
table.insert(parts, { name="", fs=get_fs(dev,status), size=unused, color=colors[c] })
end
return parts
end
for dev in nixio.fs.glob("/sys/block/*") do
if nixio.fs.access(dev .. "/md") then
local name = nixio.fs.basename(dev)
local rlevel = first_line(nixio.fs.readfile(dev .. "/md/level"))
local ndisks = tonumber(nixio.fs.readfile(dev .. "/md/raid_disks"))
local size = tonumber(nixio.fs.readfile(dev .. "/size"))
local metav = nixio.fs.readfile(dev .. "/md/metadata_version")
local degr = tonumber(nixio.fs.readfile(dev .. "/md/degraded"))
local sync = first_line(nixio.fs.readfile(dev .. "/md/sync_action"))
local sync_speed = tonumber(nixio.fs.readfile(dev .. "/md/sync_speed"))
local sync_compl = nixio.fs.readfile(dev .. "/md/sync_completed")
local status = "active"
if sync ~= "idle" then
local progress, total = nixio.fs.readfile(dev .. "/md/sync_completed"):match("^([0-9]*)[^0-9]*([0-9]*)")
local rem = (total - progress) / sync_speed / 2
local rems = math.floor(rem % 60)
if rems < 10 then rems = "0" .. rems end
rem = math.floor(rem / 60)
local remm = math.floor(rem % 60)
if remm < 10 then remm = "0" .. remm end
local remh = math.floor(rem / 60)
local remstr = remh .. ":" .. remm .. ":" .. rems
status = sync .. " (" .. math.floor(sync_speed/1024) .. "MB/s, " .. math.floor(progress * 1000 / total) /10 .. "%, rem. " .. remstr .. ")"
elseif degr == 1 then
status = "degraded"
end
local members = {}
local c = 1
for member in nixio.fs.glob("/sys/block/" .. name .. "/md/dev-*") do
local dname = nixio.fs.basename(nixio.fs.readlink(member .. "/block"))
local dsize = disp_size(tonumber(nixio.fs.readfile(member .. "/block/size")))
local dstate = nixio.fs.readfile(member .. "/state"):gsub("_", " "):match "^%s*(.-)%s*$"
table.insert(members, { name = dname, size = dsize, state = dstate, color = colors[c] })
c = c + 1
end
table.insert(raid, {name=name, rlevel=rlevel, ndisks=ndisks, size=size, metav=metav, status=status, members=members })
end
end
if show_disc == 1 then
for dev in nixio.fs.glob("/sys/class/scsi_disk/*/device") do
local section
local model = nixio.fs.readfile(dev .. "/model")
local fw = nixio.fs.readfile(dev .. "/rev")
for bdev in nixio.fs.glob(dev .. "/block/*") do
local section
local name = nixio.fs.basename(bdev)
local size = tonumber(nixio.fs.readfile(bdev .. "/size"))
local unused = size
local status = "-"
local temp = "-"
local serial = "-"
local secsize = "-"
for _,line in ipairs(luci.util.execl("smartctl -A -i -n standby -f brief /dev/" .. name)) do
local attrib, val
if section == 1 then
attrib, val = line:match "^(.*):%s*(.*)"
elseif section == 2 then
attrib, val = line:match("^([0-9 ]*) [^ ]* * [POSRCK-]* *[0-9-]* *[0-9-]* *[0-9-]* *[0-9-]* *([0-9-]*)")
else
attrib = line:match "^=== START OF (.*) SECTION ==="
if attrib == "INFORMATION" then
section = 1
elseif attrib == "READ SMART DATA" then
section = 2
elseif status == "-" then
val = line:match "^Device is in (.*) mode"
if val then
status = val:lower()
end
end
end
if not attrib then
if section ~= 2 then section = 0 end
elseif (attrib == "Power mode is") or (attrib == "Power mode was") then
status = val:lower():match "(%S*)"
elseif attrib == "Sector Sizes" then
secsize = val:match "([0-9]*) bytes physical"
elseif attrib == "Sector Size" then
secsize = val:match "([0-9]*)"
elseif attrib == "Serial Number" then
serial = val
elseif attrib == "194" then
temp = val .. "&deg;C"
end
end
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, status=status, temp=temp, serial=serial, secsize=secsize, parts=get_parts(name,status,size) })
end
end
for r,dev in ipairs(raid) do
table.insert(devinfo, {name=dev.name, model="Linux RAID", size=dev.size, status=get_status(dev), secsize=secsize, parts=get_parts(dev.name,status,dev.size) })
end
end
if show_disc == 1 then %>
<div class="cbi-section">
<h3><%:Disks%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="15%"><%:Serial number%></th>
<th width="10%"><%:Firmware%></th>
<th width="10%"><%:Capacity%></th>
<th width="5%"><%:Sector size%></th>
<th width="5%"><%:Temperature%></th>
<th width="20%"><%:Power state%></th>
</tr>
<% local style=true
for d,dev in ipairs(devinfo) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.model%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.serial%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.fw%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.secsize%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.temp%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding:0px; border-top-width:0px;" colspan="7" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,part in pairs(dev.parts) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=part.color%>" width="<%=part.perc%>%"><%=part.name%> <%=disp_size(part.size)%> <%=part.fs%></td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end
if show_raid == 1 and #raid > 0 then %>
<div class="cbi-section">
<h3><%:Raid arrays%></h3>
<table class="cbi-section-table" style="white-space:nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="13%"><%:Level%></th>
<th width="13%"><%:# Disks%></th>
<th width="13%"><%:Capacity%></th>
<th width="13%"><%:Metadata%></th>
<th width="43%"><%:Status%></th>
</tr>
<% local style=true
for r,dev in ipairs(raid) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.rlevel%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.ndisks%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.metav%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding-top:0px; border-top-width:0px" colspan="6" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,member in pairs(dev.members) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=member.color%>; white-space: nowrap"><%=member.name%> <%=member.size%> (<%=member.state%>)</td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end %>

76
my-autocore/files/common/ethinfo Normal file → Executable file
View File

@ -1,39 +1,39 @@
#!/bin/sh
a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.")
b=$(echo "$a" | wc -l)
rm -f /tmp/state/ethinfo
echo -n "[" > /tmp/state/ethinfo
for i in $(seq 1 $b)
do
h=$(echo '{"name":' )
c=$(echo "$a" | sed -n ${i}p)
d=$(ethtool $c)
e=$(echo "$d" | grep "Link detected" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
if [ $e = yes ]; then
l=1
else
l=0
fi
f=$(echo "$d" | grep "Speed" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g' | tr -d "Unknown!")
[ -z "$f" ] && f=" - "
g=$(echo "$d" | grep "Duplex" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
if [ "$g" == "Full" ]; then
x=1
else
x=0
fi
echo -n "$h \"$c\", \"status\": $l, \"speed\": \"$f\", \"duplex\": $x}," >> /tmp/state/ethinfo
done
sed -i 's/.$//' /tmp/state/ethinfo
echo -n "]" >> /tmp/state/ethinfo
#!/bin/sh
a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.")
b=$(echo "$a" | wc -l)
rm -f /tmp/state/ethinfo
echo -n "[" > /tmp/state/ethinfo
for i in $(seq 1 $b)
do
h=$(echo '{"name":' )
c=$(echo "$a" | sed -n ${i}p)
d=$(ethtool $c)
e=$(echo "$d" | grep "Link detected" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
if [ $e = yes ]; then
l=1
else
l=0
fi
f=$(echo "$d" | grep "Speed" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g' | tr -d "Unknown!")
[ -z "$f" ] && f=" - "
g=$(echo "$d" | grep "Duplex" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
if [ "$g" == "Full" ]; then
x=1
else
x=0
fi
echo -n "$h \"$c\", \"status\": $l, \"speed\": \"$f\", \"duplex\": $x}," >> /tmp/state/ethinfo
done
sed -i 's/.$//' /tmp/state/ethinfo
echo -n "]" >> /tmp/state/ethinfo
cat /tmp/state/ethinfo

106
my-autocore/files/x86/autocore Normal file → Executable file
View File

@ -1,53 +1,53 @@
#!/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=$(dmesg | grep 'DMI:' | awk -F ',' '{print $1$2 }' | awk -F ':' '{print $2 }')
h=${g}' '${b}${c}${d}${e}${f}
mkdir -p /tmp/sysinfo
echo $h > /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
[ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm
}
#!/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=$(dmesg | grep 'DMI:' | awk -F ',' '{print $1$2 }' | awk -F ':' '{print $2 }')
h=${g}' '${b}${c}${d}${e}${f}
mkdir -p /tmp/sysinfo
echo $h > /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
[ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm
}

10
my-autocore/files/x86/cpuinfo Normal file → Executable file
View File

@ -1,5 +1,5 @@
#!/bin/sh
MHz=`grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'`
TEMP=`sensors 2>/dev/null | grep 'Core 0' | cut -c12-`
echo "$MHz MHz $TEMP "
#!/bin/sh
MHz=`grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'`
TEMP=`sensors 2>/dev/null | grep 'Core 0' | cut -c12-`
echo "$MHz MHz $TEMP "

456
my-autocore/files/x86/nvme_status.htm Normal file → Executable file
View File

@ -1,228 +1,228 @@
<% local raid = {}
local devs = {}
local devinfo = {}
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "b2c005", "e0c0ff" }
local mounts = nixio.fs.readfile("/proc/mounts")
local show_raid = 1
local show_disc = 1
if self then
if self.hide_raid then
show_raid = 0
end
if self.hide_disc then
show_disc = 0
end
end
function disp_size(s)
local units = { "kB", "MB", "GB", "TB" }
local i, unit
s = s / 2
for i, unit in ipairs(units) do
if (i == #units) or (s < 1024) then
return math.floor(s * 100) / 100 .. unit
end
s = s / 1024
end
end
function first_line(s)
local n = s:find("\n")
if n then
return s:sub(1, n-1)
end
return s
end
function get_fs(pname, status)
for r,raid in ipairs(raid) do
for m,member in ipairs(raid.members) do
if member.name == pname then
return "(raid member)"
end
end
end
local mounted_fs = mounts:match("\n[a-z/]*" .. pname .. " [^ ]* ([^ ]*)")
if mounted_fs then
if status == "standby" then
return "(" .. mounted_fs .. ")"
end
local df = luci.sys.exec("df /dev/" .. pname):match(" ([0-9]+)%% ")
return "(" .. mounted_fs .. " " .. df .. "%)"
end
if status == "standby" then
return
end
local blkid = luci.sys.exec(" blkid -s TYPE /dev/" .. pname):match("TYPE=\"(.*)\"")
if blkid then
return "(" .. blkid .. ")"
end
end
function get_status(raid)
for m,member in ipairs(raid.members) do
for d,dev in ipairs(devinfo) do
if member.name == dev.name then
return dev.status
end
for p,part in ipairs(dev.parts) do
if member.name == part.name then
return dev.status
end
end
end
end
end
function get_parts(dev,status,size)
local c = 1
local unused = size
local parts = {}
for part in nixio.fs.glob("/sys/block/" .. dev .."/" .. dev .. "*") do
local pname = nixio.fs.basename(part)
local psize = nixio.fs.readfile(part .. "/size")
table.insert(parts, {name=pname, size=psize, perc=math.floor(psize*100/size), fs=get_fs(pname,status), color=colors[c]})
c = c + 1
unused = unused - psize
end
if unused > 2048 then
table.insert(parts, { name="", fs=get_fs(dev,status), size=unused, color=colors[c] })
end
return parts
end
for dev in nixio.fs.glob("/sys/block/*") do
if nixio.fs.access(dev .. "/md") then
local name = nixio.fs.basename(dev)
local rlevel = first_line(nixio.fs.readfile(dev .. "/md/level"))
local ndisks = tonumber(nixio.fs.readfile(dev .. "/md/raid_disks"))
local size = tonumber(nixio.fs.readfile(dev .. "/size"))
local metav = nixio.fs.readfile(dev .. "/md/metadata_version")
local degr = tonumber(nixio.fs.readfile(dev .. "/md/degraded"))
local sync = first_line(nixio.fs.readfile(dev .. "/md/sync_action"))
local sync_speed = tonumber(nixio.fs.readfile(dev .. "/md/sync_speed"))
local sync_compl = nixio.fs.readfile(dev .. "/md/sync_completed")
local status = "active"
if sync ~= "idle" then
local progress, total = nixio.fs.readfile(dev .. "/md/sync_completed"):match("^([0-9]*)[^0-9]*([0-9]*)")
local rem = (total - progress) / sync_speed / 2
local rems = math.floor(rem % 60)
if rems < 10 then rems = "0" .. rems end
rem = math.floor(rem / 60)
local remm = math.floor(rem % 60)
if remm < 10 then remm = "0" .. remm end
local remh = math.floor(rem / 60)
local remstr = remh .. ":" .. remm .. ":" .. rems
status = sync .. " (" .. math.floor(sync_speed/1024) .. "MB/s, " .. math.floor(progress * 1000 / total) /10 .. "%, rem. " .. remstr .. ")"
elseif degr == 1 then
status = "degraded"
end
local members = {}
local c = 1
for member in nixio.fs.glob("/sys/block/" .. name .. "/md/dev-*") do
local dname = nixio.fs.basename(nixio.fs.readlink(member .. "/block"))
local dsize = disp_size(tonumber(nixio.fs.readfile(member .. "/block/size")))
local dstate = nixio.fs.readfile(member .. "/state"):gsub("_", " "):match "^%s*(.-)%s*$"
table.insert(members, { name = dname, size = dsize, state = dstate, color = colors[c] })
c = c + 1
end
table.insert(raid, {name=name, rlevel=rlevel, ndisks=ndisks, size=size, metav=metav, status=status, members=members })
end
end
if show_disc == 1 then
for dev in nixio.fs.glob("/sys/class/nvme/*/device/nvme/*") do
local section
local model = nixio.fs.readfile(dev .. "/model")
local fw = nixio.fs.readfile(dev .. "/firmware_rev")
for bdev in nixio.fs.glob(dev .. "/nvme*") do
local section
local name = nixio.fs.basename(bdev)
local size = tonumber(nixio.fs.readfile(bdev .. "/size"))
local unused = size
local status = "-"
local temp = "-"
local serial = "-"
local secsize = "-"
for _,line in ipairs(luci.util.execl("smartctl -A -i -d nvme -n standby -f brief /dev/" .. name)) do
local attrib, val
if section == 1 then
attrib, val = line:match "^(.*):%s*(.*)"
elseif section == 2 then
attrib, val = line:match("^([0-9 ]*) [^ ]* * [POSRCK-]* *[0-9-]* *[0-9-]* *[0-9-]* *[0-9-]* *([0-9-]*)")
else
attrib = line:match "^=== START OF (.*) SECTION ==="
if attrib == "INFORMATION" then
section = 1
elseif attrib == "READ SMART DATA" then
section = 2
elseif status == "-" then
val = line:match "^Device is in (.*) mode"
if val then
status = val:lower()
end
end
end
if not attrib then
if section ~= 2 then section = 0 end
elseif (attrib == "Power mode is") or (attrib == "Power mode was") then
status = val:lower():match "(%S*)"
elseif attrib == "Serial Number" then
serial = val
elseif attrib == "194" then
temp = val .. "&deg;C"
end
end
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, serial=serial, parts=get_parts(name,status,size) })
end
end
end
if show_raid == 1 and #devinfo > 0 then %>
<div class="cbi-section">
<h3><%:NVMe SSD%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="25%"><%:Serial number%></th>
<th width="20%"><%:Firmware%></th>
<th width="20%"><%:Capacity%></th>
<!-- <th width="10%"><%:Temperature%></th>-->
</tr>
<% local style=true
for d,dev in ipairs(devinfo) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.model%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.serial%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.fw%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<!-- <td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.temp%></td>-->
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding:0px; border-top-width:0px" colspan="7" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,part in pairs(dev.parts) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=part.color%>" width="<%=part.perc%>%"><%=part.name%> <%=disp_size(part.size)%> <%=part.fs%></td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end %>
<% local raid = {}
local devs = {}
local devinfo = {}
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "b2c005", "e0c0ff" }
local mounts = nixio.fs.readfile("/proc/mounts")
local show_raid = 1
local show_disc = 1
if self then
if self.hide_raid then
show_raid = 0
end
if self.hide_disc then
show_disc = 0
end
end
function disp_size(s)
local units = { "kB", "MB", "GB", "TB" }
local i, unit
s = s / 2
for i, unit in ipairs(units) do
if (i == #units) or (s < 1024) then
return math.floor(s * 100) / 100 .. unit
end
s = s / 1024
end
end
function first_line(s)
local n = s:find("\n")
if n then
return s:sub(1, n-1)
end
return s
end
function get_fs(pname, status)
for r,raid in ipairs(raid) do
for m,member in ipairs(raid.members) do
if member.name == pname then
return "(raid member)"
end
end
end
local mounted_fs = mounts:match("\n[a-z/]*" .. pname .. " [^ ]* ([^ ]*)")
if mounted_fs then
if status == "standby" then
return "(" .. mounted_fs .. ")"
end
local df = luci.sys.exec("df /dev/" .. pname):match(" ([0-9]+)%% ")
return "(" .. mounted_fs .. " " .. df .. "%)"
end
if status == "standby" then
return
end
local blkid = luci.sys.exec(" blkid -s TYPE /dev/" .. pname):match("TYPE=\"(.*)\"")
if blkid then
return "(" .. blkid .. ")"
end
end
function get_status(raid)
for m,member in ipairs(raid.members) do
for d,dev in ipairs(devinfo) do
if member.name == dev.name then
return dev.status
end
for p,part in ipairs(dev.parts) do
if member.name == part.name then
return dev.status
end
end
end
end
end
function get_parts(dev,status,size)
local c = 1
local unused = size
local parts = {}
for part in nixio.fs.glob("/sys/block/" .. dev .."/" .. dev .. "*") do
local pname = nixio.fs.basename(part)
local psize = nixio.fs.readfile(part .. "/size")
table.insert(parts, {name=pname, size=psize, perc=math.floor(psize*100/size), fs=get_fs(pname,status), color=colors[c]})
c = c + 1
unused = unused - psize
end
if unused > 2048 then
table.insert(parts, { name="", fs=get_fs(dev,status), size=unused, color=colors[c] })
end
return parts
end
for dev in nixio.fs.glob("/sys/block/*") do
if nixio.fs.access(dev .. "/md") then
local name = nixio.fs.basename(dev)
local rlevel = first_line(nixio.fs.readfile(dev .. "/md/level"))
local ndisks = tonumber(nixio.fs.readfile(dev .. "/md/raid_disks"))
local size = tonumber(nixio.fs.readfile(dev .. "/size"))
local metav = nixio.fs.readfile(dev .. "/md/metadata_version")
local degr = tonumber(nixio.fs.readfile(dev .. "/md/degraded"))
local sync = first_line(nixio.fs.readfile(dev .. "/md/sync_action"))
local sync_speed = tonumber(nixio.fs.readfile(dev .. "/md/sync_speed"))
local sync_compl = nixio.fs.readfile(dev .. "/md/sync_completed")
local status = "active"
if sync ~= "idle" then
local progress, total = nixio.fs.readfile(dev .. "/md/sync_completed"):match("^([0-9]*)[^0-9]*([0-9]*)")
local rem = (total - progress) / sync_speed / 2
local rems = math.floor(rem % 60)
if rems < 10 then rems = "0" .. rems end
rem = math.floor(rem / 60)
local remm = math.floor(rem % 60)
if remm < 10 then remm = "0" .. remm end
local remh = math.floor(rem / 60)
local remstr = remh .. ":" .. remm .. ":" .. rems
status = sync .. " (" .. math.floor(sync_speed/1024) .. "MB/s, " .. math.floor(progress * 1000 / total) /10 .. "%, rem. " .. remstr .. ")"
elseif degr == 1 then
status = "degraded"
end
local members = {}
local c = 1
for member in nixio.fs.glob("/sys/block/" .. name .. "/md/dev-*") do
local dname = nixio.fs.basename(nixio.fs.readlink(member .. "/block"))
local dsize = disp_size(tonumber(nixio.fs.readfile(member .. "/block/size")))
local dstate = nixio.fs.readfile(member .. "/state"):gsub("_", " "):match "^%s*(.-)%s*$"
table.insert(members, { name = dname, size = dsize, state = dstate, color = colors[c] })
c = c + 1
end
table.insert(raid, {name=name, rlevel=rlevel, ndisks=ndisks, size=size, metav=metav, status=status, members=members })
end
end
if show_disc == 1 then
for dev in nixio.fs.glob("/sys/class/nvme/*/device/nvme/*") do
local section
local model = nixio.fs.readfile(dev .. "/model")
local fw = nixio.fs.readfile(dev .. "/firmware_rev")
for bdev in nixio.fs.glob(dev .. "/nvme*") do
local section
local name = nixio.fs.basename(bdev)
local size = tonumber(nixio.fs.readfile(bdev .. "/size"))
local unused = size
local status = "-"
local temp = "-"
local serial = "-"
local secsize = "-"
for _,line in ipairs(luci.util.execl("smartctl -A -i -d nvme -n standby -f brief /dev/" .. name)) do
local attrib, val
if section == 1 then
attrib, val = line:match "^(.*):%s*(.*)"
elseif section == 2 then
attrib, val = line:match("^([0-9 ]*) [^ ]* * [POSRCK-]* *[0-9-]* *[0-9-]* *[0-9-]* *[0-9-]* *([0-9-]*)")
else
attrib = line:match "^=== START OF (.*) SECTION ==="
if attrib == "INFORMATION" then
section = 1
elseif attrib == "READ SMART DATA" then
section = 2
elseif status == "-" then
val = line:match "^Device is in (.*) mode"
if val then
status = val:lower()
end
end
end
if not attrib then
if section ~= 2 then section = 0 end
elseif (attrib == "Power mode is") or (attrib == "Power mode was") then
status = val:lower():match "(%S*)"
elseif attrib == "Serial Number" then
serial = val
elseif attrib == "194" then
temp = val .. "&deg;C"
end
end
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, serial=serial, parts=get_parts(name,status,size) })
end
end
end
if show_raid == 1 and #devinfo > 0 then %>
<div class="cbi-section">
<h3><%:NVMe SSD%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="25%"><%:Serial number%></th>
<th width="20%"><%:Firmware%></th>
<th width="20%"><%:Capacity%></th>
<!-- <th width="10%"><%:Temperature%></th>-->
</tr>
<% local style=true
for d,dev in ipairs(devinfo) do %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.model%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.serial%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.fw%></td>
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
<!-- <td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.temp%></td>-->
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding:0px; border-top-width:0px" colspan="7" rowspan="2">
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
<% for _,part in pairs(dev.parts) do %>
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=part.color%>" width="<%=part.perc%>%"><%=part.name%> <%=disp_size(part.size)%> <%=part.fs%></td>
<% end %>
</tr></table>
</td>
</tr>
<tr style="height:0px" />
<% style = not style
end %>
</table>
</div>
<% end %>

104
my-default-settings/Makefile Normal file → Executable file
View File

@ -1,52 +1,52 @@
#
# Copyright (C) 2010-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=my-default-settings
PKG_VERSION:=1
PKG_RELEASE:=40
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=Default Settings
MAINTAINER:=Kiddin'
PKGARCH:=all
DEPENDS:=+luci-base +bash
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/
/etc/nginx/
endef
define Build/Prepare
chmod -R +x ./files/bin ./files/sbin ./files/etc/profile.d ./files/etc/rc.d ./files/usr/share target/*/{*,}/files/{etc/init.d,usr/bin} >/dev/null || true
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(CP) ./files/* $(1)/
echo $(BOARD)$(TARGETID)
if [ -d ./target/$(BOARD)/files/. ]; then \
$(CP) ./target/$(BOARD)/files/* $(1)/; \
fi
if [ -d ./target/$(TARGETID)/files/. ]; then \
$(CP) ./target/$(TARGETID)/files/* $(1)/; \
fi; \
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
po2lmo ./po/zh_Hans/default.po $(1)/usr/lib/lua/luci/i18n/default.zh-cn.lmo
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
#
# Copyright (C) 2010-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=my-default-settings
PKG_VERSION:=1
PKG_RELEASE:=40
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
TITLE:=Default Settings
MAINTAINER:=Kiddin'
PKGARCH:=all
DEPENDS:=+luci-base +bash
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/
/etc/nginx/
endef
define Build/Prepare
chmod -R +x ./files/bin ./files/sbin ./files/etc/profile.d ./files/etc/rc.d ./files/usr/share target/*/{*,}/files/{etc/init.d,usr/bin} >/dev/null || true
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(CP) ./files/* $(1)/
echo $(BOARD)$(TARGETID)
if [ -d ./target/$(BOARD)/files/. ]; then \
$(CP) ./target/$(BOARD)/files/* $(1)/; \
fi
if [ -d ./target/$(TARGETID)/files/. ]; then \
$(CP) ./target/$(TARGETID)/files/* $(1)/; \
fi; \
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
po2lmo ./po/zh_Hans/default.po $(1)/usr/lib/lua/luci/i18n/default.zh-cn.lmo
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

6
my-default-settings/files/etc/config/base_config Normal file → Executable file
View File

@ -1,3 +1,3 @@
config status
option version '0'
option base '1'
config status
option version '0'
option base '1'

10
my-default-settings/files/etc/config/frps Normal file → Executable file
View File

@ -1,6 +1,6 @@
config frps 'main'
option enabled '0'
option server 'frps'
option client_file '/usr/bin/frps'
option bind_port '7000'
config frps 'main'
option enabled '0'
option server 'frps'
option client_file '/usr/bin/frps'
option bind_port '7000'
option tcp_mux 'true'

62
my-default-settings/files/etc/config/nginx Normal file → Executable file
View File

@ -1,31 +1,31 @@
config main global
option uci_enable 'true'
config server '_lan'
list listen '80 default_server'
list listen '[::]:80 default_server'
option server_name 'op'
list rewrite '"^/$" $scheme://$http_host/luci/ permanent'
list rewrite '"^/cgi-bin/(.*)" $scheme://$http_host/$1 permanent'
list include 'conf.d/*.locations'
option access_log 'off; # logd openwrt'
config server '_ssl'
list listen '443 ssl'
list listen '[::]:443 ssl'
option server_name '_ssl'
list rewrite '"^/$" $scheme://$http_host/luci/ permanent'
list rewrite '"^/cgi-bin/(.*)" $scheme://$http_host/$1 permanent'
list include 'conf.d/*.locations'
option ssl_certificate '/etc/nginx/conf.d/_lan.crt'
option ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
option ssl_session_cache 'shared:SSL:32k'
option ssl_session_timeout '64m'
option access_log 'off; # logd openwrt'
config server '_redirect2ssl'
#list listen '80'
#list listen '[::]:80'
#option server_name '_redirect2ssl'
#option return '302 https://$host$request_uri'
config main global
option uci_enable 'true'
config server '_lan'
list listen '80 default_server'
list listen '[::]:80 default_server'
option server_name 'op'
list rewrite '"^/$" $scheme://$http_host/luci/ permanent'
list rewrite '"^/cgi-bin/(.*)" $scheme://$http_host/$1 permanent'
list include 'conf.d/*.locations'
option access_log 'off; # logd openwrt'
config server '_ssl'
list listen '443 ssl'
list listen '[::]:443 ssl'
option server_name '_ssl'
list rewrite '"^/$" $scheme://$http_host/luci/ permanent'
list rewrite '"^/cgi-bin/(.*)" $scheme://$http_host/$1 permanent'
list include 'conf.d/*.locations'
option ssl_certificate '/etc/nginx/conf.d/_lan.crt'
option ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
option ssl_session_cache 'shared:SSL:32k'
option ssl_session_timeout '64m'
option access_log 'off; # logd openwrt'
config server '_redirect2ssl'
#list listen '80'
#list listen '[::]:80'
#option server_name '_redirect2ssl'
#option return '302 https://$host$request_uri'

8
my-default-settings/files/etc/config/syncthing Normal file → Executable file
View File

@ -1,4 +1,4 @@
config setting 'config'
option enabled '0'
option port '8384'
config setting 'config'
option enabled '0'
option port '8384'

View File

@ -1,240 +1,240 @@
## Public DNS
# DNSPai
bogus-nxdomain=123.125.81.12
bogus-nxdomain=101.226.10.8
# Level3
bogus-nxdomain=198.105.254.11
bogus-nxdomain=104.239.213.7
## China Telecom
# Anhui Telecom
bogus-nxdomain=61.191.206.4
# Beijing Telecom
bogus-nxdomain=218.30.64.194
# Chengdu Telecom
bogus-nxdomain=61.139.8.101
bogus-nxdomain=61.139.8.102
bogus-nxdomain=61.139.8.103
bogus-nxdomain=61.139.8.104
# Fujian Telecom
bogus-nxdomain=42.123.125.237
# Gansu Telecom
bogus-nxdomain=202.100.68.117
# Guangxi Telecom
bogus-nxdomain=113.12.83.4
bogus-nxdomain=113.12.83.5
# Hainan Telecom
bogus-nxdomain=202.100.220.54
# Hangzhou Telecom
bogus-nxdomain=60.191.124.236
bogus-nxdomain=60.191.124.252
# Hebei Telecom
bogus-nxdomain=222.221.5.204
# Hunan Telecom
bogus-nxdomain=124.232.132.94
# Jiangsu Telecom
bogus-nxdomain=202.102.110.204
# Jiangxi Telecom
bogus-nxdomain=61.131.208.210
bogus-nxdomain=61.131.208.211
# Nanjing Telecom
bogus-nxdomain=202.102.110.203
bogus-nxdomain=202.102.110.205
# Shandong Telecom
bogus-nxdomain=219.146.13.36
# Shanghai Telecom
bogus-nxdomain=180.168.41.175
bogus-nxdomain=180.153.103.224
# Wuhan Telecom
bogus-nxdomain=111.175.221.58
bogus-nxdomain=61.183.1.186
# Xi'an Telecom
bogus-nxdomain=125.76.239.244
bogus-nxdomain=125.76.239.245
# Yunnan Telecom
bogus-nxdomain=222.221.5.252
bogus-nxdomain=222.221.5.253
bogus-nxdomain=220.165.8.172
bogus-nxdomain=220.165.8.174
## China Unicom
# Anhui Unicom
bogus-nxdomain=112.132.230.179
# Beijing Unicom (bjdnserror1.wo.com.cn ~ bjdnserror5.wo.com.cn)
bogus-nxdomain=202.106.199.34
bogus-nxdomain=202.106.199.35
bogus-nxdomain=202.106.199.36
bogus-nxdomain=202.106.199.37
bogus-nxdomain=202.106.199.38
# Hebei Unicom (hbdnserror1.wo.com.cn ~ hbdnserror7.wo.com.cn)
bogus-nxdomain=221.192.153.41
bogus-nxdomain=221.192.153.42
bogus-nxdomain=221.192.153.43
bogus-nxdomain=221.192.153.44
bogus-nxdomain=221.192.153.45
bogus-nxdomain=221.192.153.46
bogus-nxdomain=221.192.153.49
# Heilongjiang Unicom (hljdnserror1.wo.com.cn ~ hljdnserror5.wo.com.cn)
bogus-nxdomain=125.211.213.130
bogus-nxdomain=125.211.213.131
bogus-nxdomain=125.211.213.132
bogus-nxdomain=125.211.213.133
bogus-nxdomain=125.211.213.134
# Henan Unicom (hndnserror1.wo.com.cn ~ hndnserror7.wo.com.cn)
bogus-nxdomain=218.28.144.36
bogus-nxdomain=218.28.144.37
bogus-nxdomain=218.28.144.38
bogus-nxdomain=218.28.144.39
bogus-nxdomain=218.28.144.40
bogus-nxdomain=218.28.144.41
bogus-nxdomain=218.28.144.42
# Jilin Unicom (jldnserror1.wo.com.cn ~ jldnserror5.wo.com.cn)
bogus-nxdomain=202.98.24.121
bogus-nxdomain=202.98.24.122
bogus-nxdomain=202.98.24.123
bogus-nxdomain=202.98.24.124
bogus-nxdomain=202.98.24.125
# Liaoning Unicom (lndnserror1.wo.com.cn ~ lndnserror7.wo.com.cn)
bogus-nxdomain=60.19.29.21
bogus-nxdomain=60.19.29.22
bogus-nxdomain=60.19.29.23
bogus-nxdomain=60.19.29.24
bogus-nxdomain=60.19.29.25
bogus-nxdomain=60.19.29.26
bogus-nxdomain=60.19.29.27
# Nanfang Unicom (nfdnserror1.wo.com.cn ~ nfdnserror17.wo.com.cn)
bogus-nxdomain=220.250.64.18
bogus-nxdomain=220.250.64.19
bogus-nxdomain=220.250.64.20
bogus-nxdomain=220.250.64.21
bogus-nxdomain=220.250.64.22
bogus-nxdomain=220.250.64.23
bogus-nxdomain=220.250.64.24
bogus-nxdomain=220.250.64.25
bogus-nxdomain=220.250.64.26
bogus-nxdomain=220.250.64.27
bogus-nxdomain=220.250.64.28
bogus-nxdomain=220.250.64.29
bogus-nxdomain=220.250.64.30
bogus-nxdomain=220.250.64.225
bogus-nxdomain=220.250.64.226
bogus-nxdomain=220.250.64.227
bogus-nxdomain=220.250.64.228
# Neimenggu Unicom (nmdnserror2.wo.com.cn ~ nmdnserror4.wo.com.cn)
bogus-nxdomain=202.99.254.231
bogus-nxdomain=202.99.254.232
bogus-nxdomain=202.99.254.230
# Shandong Unicom (sddnserror1.wo.com.cn ~ sddnserror9.wo.com.cn)
bogus-nxdomain=123.129.254.11
bogus-nxdomain=123.129.254.12
bogus-nxdomain=123.129.254.13
bogus-nxdomain=123.129.254.14
bogus-nxdomain=123.129.254.15
bogus-nxdomain=123.129.254.16
bogus-nxdomain=123.129.254.17
bogus-nxdomain=123.129.254.18
bogus-nxdomain=123.129.254.19
# Shanxi Unicom (sxdnserror1.wo.com.cn ~ sxdnserror6.wo.com.cn)
bogus-nxdomain=221.204.244.36
bogus-nxdomain=221.204.244.37
bogus-nxdomain=221.204.244.38
bogus-nxdomain=221.204.244.39
bogus-nxdomain=221.204.244.40
bogus-nxdomain=221.204.244.41
# Tianjin Unicom (tjdnserror1.wo.com.cn ~ tjdnserror5.wo.com.cn)
bogus-nxdomain=218.68.250.117
bogus-nxdomain=218.68.250.118
bogus-nxdomain=218.68.250.119
bogus-nxdomain=218.68.250.120
bogus-nxdomain=218.68.250.121
## China Mobile
# Anhui Mobile
bogus-nxdomain=120.209.138.64
# Guangdong Mobile
bogus-nxdomain=211.139.136.73
bogus-nxdomain=221.179.46.190
bogus-nxdomain=221.179.46.194
# Jiangsu Mobile
bogus-nxdomain=183.207.232.253
# Jiangxi Mobile
bogus-nxdomain=223.82.248.117
# Qinghai Mobile
bogus-nxdomain=211.138.74.132
# Shaanxi Mobile
bogus-nxdomain=211.137.130.101
# Shanghai Mobile
bogus-nxdomain=211.136.113.1
# Shanxi Mobile
bogus-nxdomain=211.138.102.198
# Shandong Mobile
bogus-nxdomain=120.192.83.163
# Sichuan Mobile
bogus-nxdomain=183.221.242.172
bogus-nxdomain=183.221.250.11
# Xizang Mobile
bogus-nxdomain=111.11.208.2
# Yunnan Mobile
bogus-nxdomain=183.224.40.24
## China Tie Tong
# Shandong TieTong
bogus-nxdomain=211.98.70.226
bogus-nxdomain=211.98.70.227
bogus-nxdomain=211.98.71.195
## GWBN
# Wuhan GWBN
bogus-nxdomain=114.112.163.232
bogus-nxdomain=114.112.163.254
## Public DNS
# DNSPai
bogus-nxdomain=123.125.81.12
bogus-nxdomain=101.226.10.8
# Level3
bogus-nxdomain=198.105.254.11
bogus-nxdomain=104.239.213.7
## China Telecom
# Anhui Telecom
bogus-nxdomain=61.191.206.4
# Beijing Telecom
bogus-nxdomain=218.30.64.194
# Chengdu Telecom
bogus-nxdomain=61.139.8.101
bogus-nxdomain=61.139.8.102
bogus-nxdomain=61.139.8.103
bogus-nxdomain=61.139.8.104
# Fujian Telecom
bogus-nxdomain=42.123.125.237
# Gansu Telecom
bogus-nxdomain=202.100.68.117
# Guangxi Telecom
bogus-nxdomain=113.12.83.4
bogus-nxdomain=113.12.83.5
# Hainan Telecom
bogus-nxdomain=202.100.220.54
# Hangzhou Telecom
bogus-nxdomain=60.191.124.236
bogus-nxdomain=60.191.124.252
# Hebei Telecom
bogus-nxdomain=222.221.5.204
# Hunan Telecom
bogus-nxdomain=124.232.132.94
# Jiangsu Telecom
bogus-nxdomain=202.102.110.204
# Jiangxi Telecom
bogus-nxdomain=61.131.208.210
bogus-nxdomain=61.131.208.211
# Nanjing Telecom
bogus-nxdomain=202.102.110.203
bogus-nxdomain=202.102.110.205
# Shandong Telecom
bogus-nxdomain=219.146.13.36
# Shanghai Telecom
bogus-nxdomain=180.168.41.175
bogus-nxdomain=180.153.103.224
# Wuhan Telecom
bogus-nxdomain=111.175.221.58
bogus-nxdomain=61.183.1.186
# Xi'an Telecom
bogus-nxdomain=125.76.239.244
bogus-nxdomain=125.76.239.245
# Yunnan Telecom
bogus-nxdomain=222.221.5.252
bogus-nxdomain=222.221.5.253
bogus-nxdomain=220.165.8.172
bogus-nxdomain=220.165.8.174
## China Unicom
# Anhui Unicom
bogus-nxdomain=112.132.230.179
# Beijing Unicom (bjdnserror1.wo.com.cn ~ bjdnserror5.wo.com.cn)
bogus-nxdomain=202.106.199.34
bogus-nxdomain=202.106.199.35
bogus-nxdomain=202.106.199.36
bogus-nxdomain=202.106.199.37
bogus-nxdomain=202.106.199.38
# Hebei Unicom (hbdnserror1.wo.com.cn ~ hbdnserror7.wo.com.cn)
bogus-nxdomain=221.192.153.41
bogus-nxdomain=221.192.153.42
bogus-nxdomain=221.192.153.43
bogus-nxdomain=221.192.153.44
bogus-nxdomain=221.192.153.45
bogus-nxdomain=221.192.153.46
bogus-nxdomain=221.192.153.49
# Heilongjiang Unicom (hljdnserror1.wo.com.cn ~ hljdnserror5.wo.com.cn)
bogus-nxdomain=125.211.213.130
bogus-nxdomain=125.211.213.131
bogus-nxdomain=125.211.213.132
bogus-nxdomain=125.211.213.133
bogus-nxdomain=125.211.213.134
# Henan Unicom (hndnserror1.wo.com.cn ~ hndnserror7.wo.com.cn)
bogus-nxdomain=218.28.144.36
bogus-nxdomain=218.28.144.37
bogus-nxdomain=218.28.144.38
bogus-nxdomain=218.28.144.39
bogus-nxdomain=218.28.144.40
bogus-nxdomain=218.28.144.41
bogus-nxdomain=218.28.144.42
# Jilin Unicom (jldnserror1.wo.com.cn ~ jldnserror5.wo.com.cn)
bogus-nxdomain=202.98.24.121
bogus-nxdomain=202.98.24.122
bogus-nxdomain=202.98.24.123
bogus-nxdomain=202.98.24.124
bogus-nxdomain=202.98.24.125
# Liaoning Unicom (lndnserror1.wo.com.cn ~ lndnserror7.wo.com.cn)
bogus-nxdomain=60.19.29.21
bogus-nxdomain=60.19.29.22
bogus-nxdomain=60.19.29.23
bogus-nxdomain=60.19.29.24
bogus-nxdomain=60.19.29.25
bogus-nxdomain=60.19.29.26
bogus-nxdomain=60.19.29.27
# Nanfang Unicom (nfdnserror1.wo.com.cn ~ nfdnserror17.wo.com.cn)
bogus-nxdomain=220.250.64.18
bogus-nxdomain=220.250.64.19
bogus-nxdomain=220.250.64.20
bogus-nxdomain=220.250.64.21
bogus-nxdomain=220.250.64.22
bogus-nxdomain=220.250.64.23
bogus-nxdomain=220.250.64.24
bogus-nxdomain=220.250.64.25
bogus-nxdomain=220.250.64.26
bogus-nxdomain=220.250.64.27
bogus-nxdomain=220.250.64.28
bogus-nxdomain=220.250.64.29
bogus-nxdomain=220.250.64.30
bogus-nxdomain=220.250.64.225
bogus-nxdomain=220.250.64.226
bogus-nxdomain=220.250.64.227
bogus-nxdomain=220.250.64.228
# Neimenggu Unicom (nmdnserror2.wo.com.cn ~ nmdnserror4.wo.com.cn)
bogus-nxdomain=202.99.254.231
bogus-nxdomain=202.99.254.232
bogus-nxdomain=202.99.254.230
# Shandong Unicom (sddnserror1.wo.com.cn ~ sddnserror9.wo.com.cn)
bogus-nxdomain=123.129.254.11
bogus-nxdomain=123.129.254.12
bogus-nxdomain=123.129.254.13
bogus-nxdomain=123.129.254.14
bogus-nxdomain=123.129.254.15
bogus-nxdomain=123.129.254.16
bogus-nxdomain=123.129.254.17
bogus-nxdomain=123.129.254.18
bogus-nxdomain=123.129.254.19
# Shanxi Unicom (sxdnserror1.wo.com.cn ~ sxdnserror6.wo.com.cn)
bogus-nxdomain=221.204.244.36
bogus-nxdomain=221.204.244.37
bogus-nxdomain=221.204.244.38
bogus-nxdomain=221.204.244.39
bogus-nxdomain=221.204.244.40
bogus-nxdomain=221.204.244.41
# Tianjin Unicom (tjdnserror1.wo.com.cn ~ tjdnserror5.wo.com.cn)
bogus-nxdomain=218.68.250.117
bogus-nxdomain=218.68.250.118
bogus-nxdomain=218.68.250.119
bogus-nxdomain=218.68.250.120
bogus-nxdomain=218.68.250.121
## China Mobile
# Anhui Mobile
bogus-nxdomain=120.209.138.64
# Guangdong Mobile
bogus-nxdomain=211.139.136.73
bogus-nxdomain=221.179.46.190
bogus-nxdomain=221.179.46.194
# Jiangsu Mobile
bogus-nxdomain=183.207.232.253
# Jiangxi Mobile
bogus-nxdomain=223.82.248.117
# Qinghai Mobile
bogus-nxdomain=211.138.74.132
# Shaanxi Mobile
bogus-nxdomain=211.137.130.101
# Shanghai Mobile
bogus-nxdomain=211.136.113.1
# Shanxi Mobile
bogus-nxdomain=211.138.102.198
# Shandong Mobile
bogus-nxdomain=120.192.83.163
# Sichuan Mobile
bogus-nxdomain=183.221.242.172
bogus-nxdomain=183.221.250.11
# Xizang Mobile
bogus-nxdomain=111.11.208.2
# Yunnan Mobile
bogus-nxdomain=183.224.40.24
## China Tie Tong
# Shandong TieTong
bogus-nxdomain=211.98.70.226
bogus-nxdomain=211.98.70.227
bogus-nxdomain=211.98.71.195
## GWBN
# Wuhan GWBN
bogus-nxdomain=114.112.163.232
bogus-nxdomain=114.112.163.254

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
[ "$(uci -q get network.lan.ifname)" ] || (uci -q set network.lan.ifname="`uci -q get network.lan.device`";uci commit network)
[ "$(uci -q get network.wan.ifname)" ] || (uci -q set network.wan.ifname="`uci -q get network.wan.device`";uci commit network)
[ "$(uci -q get network.wan6.ifname)" ] || (uci -q set network.wan6.ifname="`uci -q get network.wan6.device`";uci commit network)
#!/bin/sh
#
[ "$(uci -q get network.lan.ifname)" ] || (uci -q set network.lan.ifname="`uci -q get network.lan.device`";uci commit network)
[ "$(uci -q get network.wan.ifname)" ] || (uci -q set network.wan.ifname="`uci -q get network.wan.device`";uci commit network)
[ "$(uci -q get network.wan6.ifname)" ] || (uci -q set network.wan6.ifname="`uci -q get network.wan6.device`";uci commit network)

26
my-default-settings/files/etc/nginx/conf.d/_lan.crt Normal file → Executable file
View File

@ -1,13 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICBjCCAYugAwIBAgIUGK/jDVgfzEjdhGT3KL8IgfeaQSowCgYIKoZIzj0EAwIw
ZDELMAkGA1UEBhMCWloxEjAQBgNVBAgMCVNvbWV3aGVyZTENMAsGA1UEBwwETm9u
ZTEQMA4GA1UEAwwHT3BlbldydDEgMB4GA1UECgwXT3BlbldydEQyMEEyRUJGREM3
QjM2MDMwHhcNMjEwODMwMDgwMTA3WhcNMjQxMTMwMDgwMTA3WjBkMQswCQYDVQQG
EwJaWjESMBAGA1UECAwJU29tZXdoZXJlMQ0wCwYDVQQHDAROb25lMRAwDgYDVQQD
DAdPcGVuV3J0MSAwHgYDVQQKDBdPcGVuV3J0RDIwQTJFQkZEQzdCMzYwMzB2MBAG
ByqGSM49AgEGBSuBBAAiA2IABNw+4uMTosAzmSJ8o07mhGQlnV0MPLKAKoeFL3/f
MKkNHV4GzqomRA3zx62n8GZhUDTPTyP4Ywso9ns2Z/OP0paC2yBj+EQrdGP5e1r/
UV2mjNL4JR5OCyUSVjGnYDBVRzAKBggqhkjOPQQDAgNpADBmAjEAhcVcQmeBdTFG
nykE8XDCt5NSzwawJms6i7PnTJ3I+c7u1vn6sVpoL+nxAZoCU59jAjEAnPzHfNbv
xGOuPJO3z/BPPDm9rDTX3cTNrfqsWZKndoFxqDr+UdZtk0wXdYW5Ylww
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICBjCCAYugAwIBAgIUGK/jDVgfzEjdhGT3KL8IgfeaQSowCgYIKoZIzj0EAwIw
ZDELMAkGA1UEBhMCWloxEjAQBgNVBAgMCVNvbWV3aGVyZTENMAsGA1UEBwwETm9u
ZTEQMA4GA1UEAwwHT3BlbldydDEgMB4GA1UECgwXT3BlbldydEQyMEEyRUJGREM3
QjM2MDMwHhcNMjEwODMwMDgwMTA3WhcNMjQxMTMwMDgwMTA3WjBkMQswCQYDVQQG
EwJaWjESMBAGA1UECAwJU29tZXdoZXJlMQ0wCwYDVQQHDAROb25lMRAwDgYDVQQD
DAdPcGVuV3J0MSAwHgYDVQQKDBdPcGVuV3J0RDIwQTJFQkZEQzdCMzYwMzB2MBAG
ByqGSM49AgEGBSuBBAAiA2IABNw+4uMTosAzmSJ8o07mhGQlnV0MPLKAKoeFL3/f
MKkNHV4GzqomRA3zx62n8GZhUDTPTyP4Ywso9ns2Z/OP0paC2yBj+EQrdGP5e1r/
UV2mjNL4JR5OCyUSVjGnYDBVRzAKBggqhkjOPQQDAgNpADBmAjEAhcVcQmeBdTFG
nykE8XDCt5NSzwawJms6i7PnTJ3I+c7u1vn6sVpoL+nxAZoCU59jAjEAnPzHfNbv
xGOuPJO3z/BPPDm9rDTX3cTNrfqsWZKndoFxqDr+UdZtk0wXdYW5Ylww
-----END CERTIFICATE-----

12
my-default-settings/files/etc/nginx/conf.d/_lan.key Normal file → Executable file
View File

@ -1,6 +1,6 @@
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDD8iUe1wMW2VINd9hlJqH9Nc5J4MBSCEk3KeXsC4fBOR+ubHEM2K9+I
aY+TWJsMfV6gBwYFK4EEACKhZANiAATcPuLjE6LAM5kifKNO5oRkJZ1dDDyygCqH
hS9/3zCpDR1eBs6qJkQN88etp/BmYVA0z08j+GMLKPZ7Nmfzj9KWgtsgY/hEK3Rj
+Xta/1FdpozS+CUeTgslElYxp2AwVUc=
-----END EC PRIVATE KEY-----
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDD8iUe1wMW2VINd9hlJqH9Nc5J4MBSCEk3KeXsC4fBOR+ubHEM2K9+I
aY+TWJsMfV6gBwYFK4EEACKhZANiAATcPuLjE6LAM5kifKNO5oRkJZ1dDDyygCqH
hS9/3zCpDR1eBs6qJkQN88etp/BmYVA0z08j+GMLKPZ7Nmfzj9KWgtsgY/hEK3Rj
+Xta/1FdpozS+CUeTgslElYxp2AwVUc=
-----END EC PRIVATE KEY-----

140
my-default-settings/files/etc/nginx/conf.d/shortcuts.conf Normal file → Executable file
View File

@ -1,70 +1,70 @@
# AdguardHome
server {
listen 80;
listen [::]:80;
server_name adg;
location /{
set $ip 10.0.0.1;
proxy_pass $scheme://$ip:3000;
}
}
# PVE
server {
listen 443 ssl;
listen [::]:443 ssl;
listen 80;
listen [::]:80;
server_name pve;
ssl_certificate /etc/nginx/conf.d/_lan.crt;
ssl_certificate_key /etc/nginx/conf.d/_lan.key;
location /{
proxy_pass $scheme://10.0.0.10:8006;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
}
# 青龙
server {
listen 80;
listen [::]:80;
server_name ql;
location /{
set $ip 10.0.0.1;
proxy_pass $scheme://$ip:5700;
}
}
# Bypass
server {
listen 80;
listen [::]:80;
server_name by;
return 301 $scheme://op/luci/admin/services/bypass;
}
# Packages软件包
server {
listen 80;
listen [::]:80;
server_name pk;
return 301 $scheme://op/luci/admin/system/opkg;
}
# Upgrade在线固件更新
server {
listen 80;
listen [::]:80;
server_name ug;
return 301 $scheme://op/luci/admin/services/gpsysupgrade;
}
# AriaNg
server {
listen 80;
listen [::]:80;
server_name ag;
return 301 $scheme://op/ariang;
}
# AdguardHome
server {
listen 80;
listen [::]:80;
server_name adg;
location /{
set $ip 10.0.0.1;
proxy_pass $scheme://$ip:3000;
}
}
# PVE
server {
listen 443 ssl;
listen [::]:443 ssl;
listen 80;
listen [::]:80;
server_name pve;
ssl_certificate /etc/nginx/conf.d/_lan.crt;
ssl_certificate_key /etc/nginx/conf.d/_lan.key;
location /{
proxy_pass $scheme://10.0.0.10:8006;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
}
# 青龙
server {
listen 80;
listen [::]:80;
server_name ql;
location /{
set $ip 10.0.0.1;
proxy_pass $scheme://$ip:5700;
}
}
# Bypass
server {
listen 80;
listen [::]:80;
server_name by;
return 301 $scheme://op/luci/admin/services/bypass;
}
# Packages软件包
server {
listen 80;
listen [::]:80;
server_name pk;
return 301 $scheme://op/luci/admin/system/opkg;
}
# Upgrade在线固件更新
server {
listen 80;
listen [::]:80;
server_name ug;
return 301 $scheme://op/luci/admin/services/gpsysupgrade;
}
# AriaNg
server {
listen 80;
listen [::]:80;
server_name ag;
return 301 $scheme://op/ariang;
}

View File

@ -1,42 +1,42 @@
server
{
listen 8877;
#listen 443 ssl http2;
server_name _lan;
index index.html index.htm index.php default.html default.htm default.php;
root /data;
# ssl_certificate /etc/acme/supes.top/fullchain.cer;
# ssl_certificate_key /etc/acme/supes.top/supes.top.key;
# ssl_session_timeout '64m';
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_prefer_server_ciphers on;
# ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
# ssl_session_cache 'shared:SSL:10m';
client_max_body_size 0;
location / {
set $dest $http_destination;
if (-d $request_filename) {
rewrite ^(.*[^/])$ $1/;
set $dest $dest/;
}
if ($request_method ~ (MOVE|COPY)) {
more_set_input_headers 'Destination: $dest';
}
if ($request_method ~ MKCOL) {
rewrite ^(.*[^/])$ $1/ break;
}
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;
create_full_put_path on;
auth_basic "Restricted access";
auth_basic_user_file /etc/nginx/htpasswd.conf;
}
server
{
listen 8877;
#listen 443 ssl http2;
server_name _lan;
index index.html index.htm index.php default.html default.htm default.php;
root /data;
# ssl_certificate /etc/acme/supes.top/fullchain.cer;
# ssl_certificate_key /etc/acme/supes.top/supes.top.key;
# ssl_session_timeout '64m';
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_prefer_server_ciphers on;
# ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
# ssl_session_cache 'shared:SSL:10m';
client_max_body_size 0;
location / {
set $dest $http_destination;
if (-d $request_filename) {
rewrite ^(.*[^/])$ $1/;
set $dest $dest/;
}
if ($request_method ~ (MOVE|COPY)) {
more_set_input_headers 'Destination: $dest';
}
if ($request_method ~ MKCOL) {
rewrite ^(.*[^/])$ $1/ break;
}
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;
create_full_put_path on;
auth_basic "Restricted access";
auth_basic_user_file /etc/nginx/htpasswd.conf;
}
}

0
my-default-settings/files/etc/nginx/htpasswd.conf Normal file → Executable file
View File

66
my-default-settings/files/etc/nginx/uci.conf.template Normal file → Executable file
View File

@ -1,33 +1,33 @@
# Consider using UCI or creating files in /etc/nginx/conf.d/ for configuration.
# Parsing UCI configuration is skipped if uci set nginx.global.uci_enable=false
# For details see: https://openwrt.org/docs/guide-user/services/webserver/nginx
worker_processes auto;
user root;
events {}
http {
access_log off;
log_format openwrt
'$request_method $scheme://$host$request_uri => $status'
' (${body_bytes_sent}B in ${request_time}s) <- $http_referer';
include mime.types;
default_type application/octet-stream;
sendfile on;
client_max_body_size 128M;
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
gzip on;
gzip_vary on;
gzip_proxied any;
root /www;
#UCI_HTTP_CONFIG
include conf.d/*.conf;
}
# Consider using UCI or creating files in /etc/nginx/conf.d/ for configuration.
# Parsing UCI configuration is skipped if uci set nginx.global.uci_enable=false
# For details see: https://openwrt.org/docs/guide-user/services/webserver/nginx
worker_processes auto;
user root;
events {}
http {
access_log off;
log_format openwrt
'$request_method $scheme://$host$request_uri => $status'
' (${body_bytes_sent}B in ${request_time}s) <- $http_referer';
include mime.types;
default_type application/octet-stream;
sendfile on;
client_max_body_size 128M;
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
gzip on;
gzip_vary on;
gzip_proxied any;
root /www;
#UCI_HTTP_CONFIG
include conf.d/*.conf;
}

238
my-default-settings/files/etc/profile.d/sysinfo.sh Normal file → Executable file
View File

@ -1,119 +1,119 @@
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export LANG=zh_CN.UTF-8
THIS_SCRIPT="sysinfo"
MOTD_DISABLE=""
SHOW_IP_PATTERN="^[ewr].*|^br.*|^lt.*|^umts.*"
DATA_STORAGE=/userdisk/data
MEDIA_STORAGE=/userdisk/snail
# don't edit below here
function display()
{
# $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{
# battery red color is opposite, lower number
if [[ "$1" == "Battery" ]]; then
local great="<";
else
local great=">";
fi
if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then
printf "%-14s%s" "$1:"
if awk "BEGIN{exit ! ($2 $great $3)}"; then
echo -ne "\e[0;91m $2";
else
echo -ne "\e[0;92m $2";
fi
printf "%-1s%s\x1B[0m" "$5"
printf "%-11s%s\t" "$6"
return 1
fi
} # display
function get_ip_addresses()
{
local ips=()
for f in /sys/class/net/*; do
local intf=$(basename $f)
# match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra<number> format)
if [[ $intf =~ $SHOW_IP_PATTERN ]]; then
local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1)
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
# add IP only
[[ -n $tmp ]] && ips+=("$tmp")
fi
done
echo "${ips[@]}"
} # get_ip_addresses
function storage_info()
{
# storage info
RootInfo=$(df -h /)
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
} # 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 :)
storage_info
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
# get uptime, logged in users and load in one take
UptimeString=$(uptime | tr -d ',')
time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}")
load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")"
case ${time} in
1:*) # 1-2 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*:*) # 2-24 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*day) # days
days=$(awk -F" " '{print $3"天"}' <<<"${UptimeString}")
time=$(awk -F" " '{print $5}' <<<"${UptimeString}")
time="$days "$(awk -F":" '{print $1"小时 "$2"分钟"}' <<<"${time}")
;;
esac
# memory and swap
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6))/$2) * 100)}' <<<${mem_info})
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
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})
c=0
while [ ! -n "$(get_ip_addresses)" ];do
[ $c -eq 10 ] && break || let c++
sleep 1
done
ip_address="$(get_ip_addresses)"
# display info
display "系统负载" "${load%% *}" "${critical_load}" "0" "" "${load#* }"
printf "运行时间: \x1B[92m%s\x1B[0m\t\t" "$time"
echo "" # fixed newline
display "内存已用" "$memory_usage" "70" "0" " %" " of ${memory_total}MB"
display "交换内存" "$swap_usage" "10" "0" " %" " of $swap_total""Mb"
printf "IP 地址: \x1B[92m%s\x1B[0m" "$ip_address"
echo "" # fixed newline
display "系统存储" "$root_usage" "90" "1" "%" " of $root_total"
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d '(' -f -1`)"
echo ""
echo ""
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export LANG=zh_CN.UTF-8
THIS_SCRIPT="sysinfo"
MOTD_DISABLE=""
SHOW_IP_PATTERN="^[ewr].*|^br.*|^lt.*|^umts.*"
DATA_STORAGE=/userdisk/data
MEDIA_STORAGE=/userdisk/snail
# don't edit below here
function display()
{
# $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{
# battery red color is opposite, lower number
if [[ "$1" == "Battery" ]]; then
local great="<";
else
local great=">";
fi
if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then
printf "%-14s%s" "$1:"
if awk "BEGIN{exit ! ($2 $great $3)}"; then
echo -ne "\e[0;91m $2";
else
echo -ne "\e[0;92m $2";
fi
printf "%-1s%s\x1B[0m" "$5"
printf "%-11s%s\t" "$6"
return 1
fi
} # display
function get_ip_addresses()
{
local ips=()
for f in /sys/class/net/*; do
local intf=$(basename $f)
# match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra<number> format)
if [[ $intf =~ $SHOW_IP_PATTERN ]]; then
local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1)
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
# add IP only
[[ -n $tmp ]] && ips+=("$tmp")
fi
done
echo "${ips[@]}"
} # get_ip_addresses
function storage_info()
{
# storage info
RootInfo=$(df -h /)
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
} # 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 :)
storage_info
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
# get uptime, logged in users and load in one take
UptimeString=$(uptime | tr -d ',')
time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}")
load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")"
case ${time} in
1:*) # 1-2 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*:*) # 2-24 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*day) # days
days=$(awk -F" " '{print $3"天"}' <<<"${UptimeString}")
time=$(awk -F" " '{print $5}' <<<"${UptimeString}")
time="$days "$(awk -F":" '{print $1"小时 "$2"分钟"}' <<<"${time}")
;;
esac
# memory and swap
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6))/$2) * 100)}' <<<${mem_info})
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
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})
c=0
while [ ! -n "$(get_ip_addresses)" ];do
[ $c -eq 10 ] && break || let c++
sleep 1
done
ip_address="$(get_ip_addresses)"
# display info
display "系统负载" "${load%% *}" "${critical_load}" "0" "" "${load#* }"
printf "运行时间: \x1B[92m%s\x1B[0m\t\t" "$time"
echo "" # fixed newline
display "内存已用" "$memory_usage" "70" "0" " %" " of ${memory_total}MB"
display "交换内存" "$swap_usage" "10" "0" " %" " of $swap_total""Mb"
printf "IP 地址: \x1B[92m%s\x1B[0m" "$ip_address"
echo "" # fixed newline
display "系统存储" "$root_usage" "90" "1" "%" " of $root_total"
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d '(' -f -1`)"
echo ""
echo ""

28
my-default-settings/files/etc/rc.d/S99cpumark Normal file → Executable file
View File

@ -1,14 +1,14 @@
#!/bin/sh /etc/rc.common
[[ -f "/bin/coremark" && ! -f "/etc/bench.log" && "$(uci -q get wizard.default.coremark)" == '1' ]] && {
(
sleep 5
while :; do
[ -f /var/lock/opkg.lock ] || {
/sbin/cpumark
break;
}
sleep 1
done
) &
}
#!/bin/sh /etc/rc.common
[[ -f "/bin/coremark" && ! -f "/etc/bench.log" && "$(uci -q get wizard.default.coremark)" == '1' ]] && {
(
sleep 5
while :; do
[ -f /var/lock/opkg.lock ] || {
/sbin/cpumark
break;
}
sleep 1
done
) &
}

View File

@ -1,220 +1,220 @@
#!/bin/sh
([ -x /bin/bash ] && ! grep -q "^root.*bash" /etc/passwd) && sed -i "s/^\(root.*\/\)ash/\1bash/g" /etc/passwd
# [[ "$(df | grep overlay)" && ! "$(df | grep /rom/overlay)" ]] && firstboot
version=`uci -q get base_config.@status[0].version`
. /etc/openwrt_release
test -n "${DISTRIB_ID}" || DISTRIB_ID=OpenWrt
DISTRIB_ID=`echo -n $DISTRIB_ID | tr a-z A-Z`
if [ "$(uci -q get dhcp.@dnsmasq[0].port)" != "53" ]; then
uci -q set dhcp.@dnsmasq[0].port='53'
uci commit dhcp
fi
uci -q batch <<EOF
set attendedsysupgrade.server.url='https://op.supes.top'
commit attendedsysupgrade
EOF
uci set dockerd.firewall.extra_iptables_args='--match conntrack ! --ctstate RELATED,ESTABLISHED'
uci commit dockerd
sed -i '/profile.d/d' /lib/upgrade/keep.d/base-files
echo $(uci -q get uhttpd.main.index_page) | grep -q "cgi-bin/luci" ||
uci -q add_list uhttpd.main.index_page='cgi-bin/luci' && uci commit uhttpd
/etc/init.d/wizard disable
[ -f /usr/bin/wget ] &&
ln -s /usr/bin/wget /usr/bin/wget-ssl
sed -i "s/git-.*-\(.*\)/git-\1/g" /usr/lib/lua/luci/version.lua
[[ "$(echo "$(/sbin/cpuinfo 2>/dev/null)" | grep -i "MHz")" ]] || sed -i "s/_('CPU Info'),cpuinfo.cpufreq,//" /www/luci-static/resources/view/status/include/10_system.js
grep -q op.supes.top /etc/bypass/white.list ||
echo "op.supes.top" >> /etc/bypass/white.list
processor=`cat /proc/cpuinfo | grep 'processor' | wc -l`
test -n "$processor" || processor=3
sed -i "/^threads =/c\threads = $processor" /etc/uwsgi/vassals/luci-webui.ini
test $version -lt 1 && {
uci -q set luci.main.lang='auto'
uci -q set luci.main.mediaurlbase=/luci-static/edge
uci commit luci
uci -q set dropbear.@dropbear[0].Interface='lan'
uci commit dropbear
uci -q get system.@system[0] >/dev/null 2>&1 && {
uci -q set system.@system[0].hostname="${DISTRIB_ID}"
uci -q set system.@system[0].zonename='Asia/Shanghai'
uci -q set system.@system[0].timezone='CST-8'
uci -q del system.ntp.server
uci -q add_list system.ntp.server='ntp.aliyun.com'
uci -q add_list system.ntp.server='0.openwrt.pool.ntp.org'
uci commit system
}
uci -q set uhttpd.main.rfc1918_filter=0
uci -q set uhttpd.main.redirect_https=0
uci -q set uhttpd.main.script_timeout='120'
uci commit uhttpd
(echo "root"; sleep 1; echo "root") | /bin/busybox passwd root >/dev/null 2>&1 &
wifi_setup_radio(){
local radio=$1
uci -q get wireless.${radio} >/dev/null 2>&1 && {
uci -q batch <<-EOT
set -q wireless.${radio}.disabled='0'
EOT
if [ "$(uci -q get wireless.${radio}.hwmode)" = "11a" ]; then
uci -q set wireless.${radio}.htmode='VHT80'
else
uci -q set wireless.${radio}.htmode='VHT40'
fi
obj=`uci -q add wireless wifi-iface`
test -n "$obj" && {
uci -q set wireless.$obj.device="${radio}"
uci -q set wireless.$obj.network='lan'
uci -q set wireless.$obj.mode='ap'
if [ "$(uci -q get wireless.${radio}.hwmode)" == "11a" ]; then
uci -q set wireless.$obj.ssid="${SSID}_5G"
else
uci -q set wireless.$obj.ssid="${SSID}_2.4G"
fi
if [ "${SSID_PASSWD}" ]; then
uci -q set wireless.$obj.encryption='psk2'
uci -q set wireless.$obj.key="${SSID_PASSWD}"
else
uci -q set wireless.$obj.encryption='none'
fi
}
}
}
[ -f /etc/config/wireless ] && {
SSID=${DISTRIB_ID}
SSID_PASSWD=""
while uci delete wireless.@wifi-iface[0] >/dev/null 2>&1; do :; done
for radio in radio0 radio1 radio2 radio3 wifi0 wifi1 wifi2 wifi3; do
wifi_setup_radio ${radio}
done
uci commit wireless
}
uci -q set upnpd.config.enabled='1'
uci commit upnpd
grep -q log-facility /etc/dnsmasq.conf ||
echo "log-facility=/dev/null" >> /etc/dnsmasq.conf
grep -q /etc/dnsmasq.d /etc/dnsmasq.conf ||
echo "conf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf
uci -q set firewall.@defaults[0].fullcone='1'
uci commit firewall
uci -q set fstab.@global[0].anon_mount=1
uci commit fstab
uci -q set network.lan.ipaddr="10.0.0.1"
uci -q set network.@globals[0].packet_steering=1
uci commit network
uci -q set dhcp.@dnsmasq[0].dns_redirect='1'
uci -q set dhcp.@dnsmasq[0].allservers='1'
uci -q del dhcp.@dnsmasq[0].noresolv
uci -q set dhcp.@dnsmasq[0].cachesize='1500'
uci -q set dhcp.@dnsmasq[0].min_ttl='3600'
uci -q set dhcp.lan.force='1'
uci -q set dhcp.lan.ra='hybrid'
uci -q set dhcp.lan.ndp='hybrid'
uci -q set dhcp.lan.dhcpv6='hybrid'
uci -q set dhcp.lan.force='1'
uci commit dhcp
uci -q set nft-qos.default.limit_enable='0'
uci commit nft-qos
uci -q set system.@system[0].conloglevel='4'
uci -q set system.@system[0].cronloglevel='8'
uci commit system
}
# kB
memtotal=`grep MemTotal /proc/meminfo | awk '{print $2}'`
if test $memtotal -ge 1048576; then
# > 1024M
cachesize=10000
dnsforwardmax=10000
nf_conntrack_max=262144
elif test $memtotal -ge 524288; then
# <= 1024M
cachesize=10000
dnsforwardmax=10000
nf_conntrack_max=131072
elif test $memtotal -ge 262144; then
# <= 512M
cachesize=8192
dnsforwardmax=8192
nf_conntrack_max=65536
elif test $memtotal -ge 131072; then
# <= 256M
cachesize=4096
dnsforwardmax=4096
nf_conntrack_max=65536
elif test $memtotal -ge 65536; then
# <= 128M
cachesize=2048
dnsforwardmax=2048
nf_conntrack_max=32768
else
# < 64M
cachesize=1024
dnsforwardmax=1024
nf_conntrack_max=16384
fi
test $version -lt 1 && {
uci -q get dhcp.@dnsmasq[0] || uci -q add dhcp dnsmasq
uci -q set dhcp.@dnsmasq[0].cachesize="$cachesize"
uci -q set dhcp.@dnsmasq[0].dnsforwardmax="$dnsforwardmax"
uci -q set dhcp.@dnsmasq[0].localservice='0'
uci -q set dhcp.@dnsmasq[0].localise_queries='1'
uci -q set dhcp.@dnsmasq[0].rebind_protection='0'
uci -q set dhcp.@dnsmasq[0].rebind_localhost='1'
uci commit dhcp
uci -q set system.@system[0].zram_comp_algo='zstd'
uci -q set system.@system[0].zram_size_mb="$(expr $memtotal / 1024 / 3)"
uci commit system
version=1
}
# sysctl overwrite
SYSCTL_LOCAL=/etc/sysctl.d/50-local.conf
mkdir -p /etc/sysctl.d
echo -n >$SYSCTL_LOCAL
echo net.nf_conntrack_max=$nf_conntrack_max >>$SYSCTL_LOCAL
echo net.ipv4.ip_early_demux=0 >>$SYSCTL_LOCAL
echo net.bridge.bridge-nf-call-iptables=0 >>$SYSCTL_LOCAL
echo net.ipv4.fib_multipath_hash_policy=1 >>$SYSCTL_LOCAL
echo net.ipv4.tcp_congestion_control=cubic >>$SYSCTL_LOCAL
echo net.netfilter.nf_conntrack_helper=1 >>$SYSCTL_LOCAL
echo kernel.msgmax = 65536 >>$SYSCTL_LOCAL
echo kernel.msgmnb = 65536 >>$SYSCTL_LOCAL
echo vm.swappiness=0 >>$SYSCTL_LOCAL
cp -pR /www/cgi-bin/* /www/
rm -rf /tmp/luci-*
uci -q set base_config.@status[0].version=$version
uci commit base_config
#!/bin/sh
([ -x /bin/bash ] && ! grep -q "^root.*bash" /etc/passwd) && sed -i "s/^\(root.*\/\)ash/\1bash/g" /etc/passwd
# [[ "$(df | grep overlay)" && ! "$(df | grep /rom/overlay)" ]] && firstboot
version=`uci -q get base_config.@status[0].version`
. /etc/openwrt_release
test -n "${DISTRIB_ID}" || DISTRIB_ID=OpenWrt
DISTRIB_ID=`echo -n $DISTRIB_ID | tr a-z A-Z`
if [ "$(uci -q get dhcp.@dnsmasq[0].port)" != "53" ]; then
uci -q set dhcp.@dnsmasq[0].port='53'
uci commit dhcp
fi
uci -q batch <<EOF
set attendedsysupgrade.server.url='https://op.dllkids.xyz'
commit attendedsysupgrade
EOF
uci set dockerd.firewall.extra_iptables_args='--match conntrack ! --ctstate RELATED,ESTABLISHED'
uci commit dockerd
sed -i '/profile.d/d' /lib/upgrade/keep.d/base-files
echo $(uci -q get uhttpd.main.index_page) | grep -q "cgi-bin/luci" ||
uci -q add_list uhttpd.main.index_page='cgi-bin/luci' && uci commit uhttpd
/etc/init.d/wizard disable
[ -f /usr/bin/wget ] &&
ln -s /usr/bin/wget /usr/bin/wget-ssl
sed -i "s/git-.*-\(.*\)/git-\1/g" /usr/lib/lua/luci/version.lua
[[ "$(echo "$(/sbin/cpuinfo 2>/dev/null)" | grep -i "MHz")" ]] || sed -i "s/_('CPU Info'),cpuinfo.cpufreq,//" /www/luci-static/resources/view/status/include/10_system.js
grep -q op.dllkids.xyz /etc/bypass/white.list ||
echo "op.dllkids.xyz" >> /etc/bypass/white.list
processor=`cat /proc/cpuinfo | grep 'processor' | wc -l`
test -n "$processor" || processor=3
sed -i "/^threads =/c\threads = $processor" /etc/uwsgi/vassals/luci-webui.ini
test $version -lt 1 && {
uci -q set luci.main.lang='auto'
uci -q set luci.main.mediaurlbase=/luci-static/edge
uci commit luci
uci -q set dropbear.@dropbear[0].Interface='lan'
uci commit dropbear
uci -q get system.@system[0] >/dev/null 2>&1 && {
uci -q set system.@system[0].hostname="${DISTRIB_ID}"
uci -q set system.@system[0].zonename='Asia/Shanghai'
uci -q set system.@system[0].timezone='CST-8'
uci -q del system.ntp.server
uci -q add_list system.ntp.server='ntp.aliyun.com'
uci -q add_list system.ntp.server='0.openwrt.pool.ntp.org'
uci commit system
}
uci -q set uhttpd.main.rfc1918_filter=0
uci -q set uhttpd.main.redirect_https=0
uci -q set uhttpd.main.script_timeout='120'
uci commit uhttpd
(echo "root"; sleep 1; echo "root") | /bin/busybox passwd root >/dev/null 2>&1 &
wifi_setup_radio(){
local radio=$1
uci -q get wireless.${radio} >/dev/null 2>&1 && {
uci -q batch <<-EOT
set -q wireless.${radio}.disabled='0'
EOT
if [ "$(uci -q get wireless.${radio}.hwmode)" = "11a" ]; then
uci -q set wireless.${radio}.htmode='VHT80'
else
uci -q set wireless.${radio}.htmode='VHT40'
fi
obj=`uci -q add wireless wifi-iface`
test -n "$obj" && {
uci -q set wireless.$obj.device="${radio}"
uci -q set wireless.$obj.network='lan'
uci -q set wireless.$obj.mode='ap'
if [ "$(uci -q get wireless.${radio}.hwmode)" == "11a" ]; then
uci -q set wireless.$obj.ssid="${SSID}_5G"
else
uci -q set wireless.$obj.ssid="${SSID}_2.4G"
fi
if [ "${SSID_PASSWD}" ]; then
uci -q set wireless.$obj.encryption='psk2'
uci -q set wireless.$obj.key="${SSID_PASSWD}"
else
uci -q set wireless.$obj.encryption='none'
fi
}
}
}
[ -f /etc/config/wireless ] && {
SSID=${DISTRIB_ID}
SSID_PASSWD=""
while uci delete wireless.@wifi-iface[0] >/dev/null 2>&1; do :; done
for radio in radio0 radio1 radio2 radio3 wifi0 wifi1 wifi2 wifi3; do
wifi_setup_radio ${radio}
done
uci commit wireless
}
uci -q set upnpd.config.enabled='1'
uci commit upnpd
grep -q log-facility /etc/dnsmasq.conf ||
echo "log-facility=/dev/null" >> /etc/dnsmasq.conf
grep -q /etc/dnsmasq.d /etc/dnsmasq.conf ||
echo "conf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf
uci -q set firewall.@defaults[0].fullcone='1'
uci commit firewall
uci -q set fstab.@global[0].anon_mount=1
uci commit fstab
uci -q set network.lan.ipaddr="10.0.0.1"
uci -q set network.@globals[0].packet_steering=1
uci commit network
uci -q set dhcp.@dnsmasq[0].dns_redirect='1'
uci -q set dhcp.@dnsmasq[0].allservers='1'
uci -q del dhcp.@dnsmasq[0].noresolv
uci -q set dhcp.@dnsmasq[0].cachesize='1500'
uci -q set dhcp.@dnsmasq[0].min_ttl='3600'
uci -q set dhcp.lan.force='1'
uci -q set dhcp.lan.ra='hybrid'
uci -q set dhcp.lan.ndp='hybrid'
uci -q set dhcp.lan.dhcpv6='hybrid'
uci -q set dhcp.lan.force='1'
uci commit dhcp
uci -q set nft-qos.default.limit_enable='0'
uci commit nft-qos
uci -q set system.@system[0].conloglevel='4'
uci -q set system.@system[0].cronloglevel='8'
uci commit system
}
# kB
memtotal=`grep MemTotal /proc/meminfo | awk '{print $2}'`
if test $memtotal -ge 1048576; then
# > 1024M
cachesize=10000
dnsforwardmax=10000
nf_conntrack_max=262144
elif test $memtotal -ge 524288; then
# <= 1024M
cachesize=10000
dnsforwardmax=10000
nf_conntrack_max=131072
elif test $memtotal -ge 262144; then
# <= 512M
cachesize=8192
dnsforwardmax=8192
nf_conntrack_max=65536
elif test $memtotal -ge 131072; then
# <= 256M
cachesize=4096
dnsforwardmax=4096
nf_conntrack_max=65536
elif test $memtotal -ge 65536; then
# <= 128M
cachesize=2048
dnsforwardmax=2048
nf_conntrack_max=32768
else
# < 64M
cachesize=1024
dnsforwardmax=1024
nf_conntrack_max=16384
fi
test $version -lt 1 && {
uci -q get dhcp.@dnsmasq[0] || uci -q add dhcp dnsmasq
uci -q set dhcp.@dnsmasq[0].cachesize="$cachesize"
uci -q set dhcp.@dnsmasq[0].dnsforwardmax="$dnsforwardmax"
uci -q set dhcp.@dnsmasq[0].localservice='0'
uci -q set dhcp.@dnsmasq[0].localise_queries='1'
uci -q set dhcp.@dnsmasq[0].rebind_protection='0'
uci -q set dhcp.@dnsmasq[0].rebind_localhost='1'
uci commit dhcp
uci -q set system.@system[0].zram_comp_algo='zstd'
uci -q set system.@system[0].zram_size_mb="$(expr $memtotal / 1024 / 3)"
uci commit system
version=1
}
# sysctl overwrite
SYSCTL_LOCAL=/etc/sysctl.d/50-local.conf
mkdir -p /etc/sysctl.d
echo -n >$SYSCTL_LOCAL
echo net.nf_conntrack_max=$nf_conntrack_max >>$SYSCTL_LOCAL
echo net.ipv4.ip_early_demux=0 >>$SYSCTL_LOCAL
echo net.bridge.bridge-nf-call-iptables=0 >>$SYSCTL_LOCAL
echo net.ipv4.fib_multipath_hash_policy=1 >>$SYSCTL_LOCAL
echo net.ipv4.tcp_congestion_control=cubic >>$SYSCTL_LOCAL
echo net.netfilter.nf_conntrack_helper=1 >>$SYSCTL_LOCAL
echo kernel.msgmax = 65536 >>$SYSCTL_LOCAL
echo kernel.msgmnb = 65536 >>$SYSCTL_LOCAL
echo vm.swappiness=0 >>$SYSCTL_LOCAL
cp -pR /www/cgi-bin/* /www/
rm -rf /tmp/luci-*
uci -q set base_config.@status[0].version=$version
uci commit base_config

6
my-default-settings/files/sbin/cpumark Normal file → Executable file
View File

@ -1,3 +1,3 @@
#!/bin/ash
/bin/coremark | grep "CoreMark 1.0" | cut -d "/" -f 1 | cut -d "." -f -2 | sed -e 's/CoreMark 1.0\(.*\)/(CpuMark\1 Scores)/g' | tee /etc/bench.log
#!/bin/ash
/bin/coremark | grep "CoreMark 1.0" | cut -d "/" -f 1 | cut -d "." -f -2 | sed -e 's/CoreMark 1.0\(.*\)/(CpuMark\1 Scores)/g' | tee /etc/bench.log

136
my-default-settings/files/sbin/shutdown Normal file → Executable file
View File

@ -1,68 +1,68 @@
#!/bin/ash
# 默认使用关机命令
ACTION="poweroff"
# 获取shutdown参数
# Qemu-GA 默认调用 -h -P +0的方式
while [ -n "$1" ]; do
case "$1" in
-r)
ACTION="reboot"
shift
;;
-k)
ACTION="warning"
shift
;;
-h|-H)
ACTION="halt"
shift
;;
-n)
ACTION="poweroff"
shift
;;
-c)
echo "Cancel shutdown, but not support the Openwrt!" > /dev/kmsg
ACTION="stop"
shift
;;
-p|-P)
ACTION="poweroff"
shift
;;
-*)
shift
;;
*)
break
;;
esac
done
if [ $# == 0 ]; then
echo "Shutting down without any params" > /dev/kmsg
/sbin/poweroff
elif [ "$ACTION" = "poweroff" ]; then
/sbin/poweroff;
elif [ "$ACTION" = "reboot" ]; then
/sbin/reboot
elif [ "$ACTION" = "warning" ]; then
echo "关机警告">/dev/kmsg
/sbin/poweroff;
elif [ "$ACTION" = "halt" ]; then
/sbin/halt
fi
#!/bin/ash
# 默认使用关机命令
ACTION="poweroff"
# 获取shutdown参数
# Qemu-GA 默认调用 -h -P +0的方式
while [ -n "$1" ]; do
case "$1" in
-r)
ACTION="reboot"
shift
;;
-k)
ACTION="warning"
shift
;;
-h|-H)
ACTION="halt"
shift
;;
-n)
ACTION="poweroff"
shift
;;
-c)
echo "Cancel shutdown, but not support the Openwrt!" > /dev/kmsg
ACTION="stop"
shift
;;
-p|-P)
ACTION="poweroff"
shift
;;
-*)
shift
;;
*)
break
;;
esac
done
if [ $# == 0 ]; then
echo "Shutting down without any params" > /dev/kmsg
/sbin/poweroff
elif [ "$ACTION" = "poweroff" ]; then
/sbin/poweroff;
elif [ "$ACTION" = "reboot" ]; then
/sbin/reboot
elif [ "$ACTION" = "warning" ]; then
echo "关机警告">/dev/kmsg
/sbin/poweroff;
elif [ "$ACTION" = "halt" ]; then
/sbin/halt
fi

View File

@ -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/opwrts" target="_blank">TG交流(小粉红勿扰)</a></div><div class="td left" width="33%"><a href="https://github.com/kiddin9/OpenWrt_x86-r2s-r4s" target="_blank">源码与反馈</a></div><div class="td left"><a href="https://bf.supes.top/" 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/opwrts" target="_blank">TG交流</a></div><div class="td left" width="33%"><a href="https://github.com/kenzok78/Bulid_Wrt" target="_blank">源码与反馈</a></div><div class="td left"><a href="https://op.dllkids.xyz/" target="_blank">固件下载</a></div></div></div>';
var telegram = document.querySelectorAll(".cbi-section")[0];
telegram.appendChild(links);
}, 2000);
</script>

338
my-default-settings/po/zh_Hans/default.po Normal file → Executable file
View File

@ -1,169 +1,169 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2021-04-12 14:21+0000\n"
"Language: zh_Hans\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 4.5-dev\n"
msgid "Processor"
msgstr "处理器"
msgid "Architecture"
msgstr "架构"
msgid "CPU Temperature"
msgstr "CPU 温度"
msgid "CPU Info"
msgstr "CPU 信息"
msgid "CPU Model"
msgstr "处理器型号"
msgid "CPU frequency"
msgstr "CPU 频率"
msgid "RAM frequency"
msgstr "RAM 频率"
msgid "Flash Size"
msgstr "闪存大小"
msgid "Free Memory"
msgstr "释放内存"
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "ZRam Settings"
msgstr "ZRam 设置"
msgid "ZRam Compression Algorithm"
msgstr "ZRam 压缩算法"
msgid "ZRam Compression Streams"
msgstr "ZRam 压缩数据流线程数"
msgid "ZRam Size"
msgstr "ZRam 大小"
msgid "Size of the ZRam device in megabytes"
msgstr "划分给 ZRam 分区的内存大小MB推荐留空由系统自动管理"
msgid "Number of parallel threads used for compression"
msgstr "用于压缩内存数据的CPU并发线程数"
msgid "Swap"
msgstr "虚拟内存"
msgid "Swap used"
msgstr "已用交换区"
msgid "Force 40MHz mode"
msgstr "强制 40MHz 频宽"
msgid ""
"Always use 40MHz channels even if the secondary channel overlaps. Using this "
"option does not comply with IEEE 802.11n-2009!"
msgstr "强制启用 40MHz 频宽并忽略辅助信道重叠。此选项可能不兼容某些无线硬件导致无法启用!"
msgid "Disassociate On Low Acknowledgement"
msgstr "弱信号剔除"
msgid "Allow AP mode to disconnect STAs based on low ACK condition"
msgstr "允许 AP 模式基于低 ACK 条件判断剔除弱信号的客户端"
msgid "Running Status"
msgstr "运行状况"
msgid "Online Users"
msgstr "在线用户数"
msgid "DNS Redirect"
msgstr "DNS 重定向"
msgid "Redirect client DNS to dnsmasq"
msgstr "重定向客户端DNS到dnsmasq"
msgid "Enable 256-QAM"
msgstr "启用 256-QAM"
msgid "802.11n 2.4Ghz Only"
msgstr "只适合 802.11n 2.4Ghz"
msgid "Enables The 802.11k standard provides information to discover the best available access point"
msgstr "启用 802.11k 自动寻找发现最佳可用接入点的信息"
msgid "Enable neighbor report via radio measurements"
msgstr "启用无线电测量邻居报告"
msgid "Enable beacon report via radio measurements"
msgstr "启用无线电测量信标报告"
msgid "Enables 802.11v allows client devices to exchange information about the network topology,tating overall improvement of the wireless network."
msgstr "启用 802.11v 将允许客户端设备交换有关网络拓扑的信息,从而全面改善无线网络漫游"
msgid "extended sleep mode for stations"
msgstr "扩展无线休眠节能模式"
msgid "BSS Transition Management"
msgstr "BSS 传输管理"
msgid "UTC time at which the TSF timer is 0"
msgstr "TSF计时器为0的UTC时间"
msgid "Time advertisement"
msgstr "广播同步时间"
msgid "time zone"
msgstr "时区"
msgid "Local time zone as specified in 8.3 of IEEE Std 1003.1-2004"
msgstr "本地时区采用 IEEE Std 1003.1-2004 的 8.3 格式(例如 UTC8"
msgid "Custom Redirect Domain"
msgstr "自定义挟持域名"
msgid "Define a custom domain name and the corresponding PTR record"
msgstr "自定义域名对应的IP地址需要客户端DNS指向本路由"
msgid "Domain Name"
msgstr "域名(不带 HTTP(S)://"
msgid "Comments"
msgstr "备注"
msgid "Retain the current packages"
msgstr "保留已安装软件包"
msgid "Packet Steering"
msgstr "数据包引导"
msgid "Enable packet steering across all CPUs. May help or hinder network speed."
msgstr "启用所有CPU的数据包控制。 可能有助于或阻碍网络速度。"
msgid "Disable IPv6 DNS forwards"
msgstr "禁止解析 IPv6 DNS 记录"
msgid "Filter IPv6(AAAA) DNS Query Name Resolve"
msgstr "过滤掉 IPv6(AAAA) ,只返回 IPv4 DNS 域名记录"
msgid "Minimum TTL to send to clients"
msgstr "客户端缓存的最小 DNS TTL"
msgid "Modify DNS entries minimum TTL (max is 86400, 0 is no modify)"
msgstr "修改发送到客户端的域名记录的 TTL 时间 (最大 86400, 0 表示不修改)"
msgid "FullCone NAT"
msgstr "全锥形 NAT"
msgid "Using FullCone NAT can improve gaming performance effectively"
msgstr "使用全锥形 NAT 可以有效提升游戏体验"
msgid "Used space"
msgstr "已用空间"
msgid ""
msgstr ""
"PO-Revision-Date: 2021-04-12 14:21+0000\n"
"Language: zh_Hans\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 4.5-dev\n"
msgid "Processor"
msgstr "处理器"
msgid "Architecture"
msgstr "架构"
msgid "CPU Temperature"
msgstr "CPU 温度"
msgid "CPU Info"
msgstr "CPU 信息"
msgid "CPU Model"
msgstr "处理器型号"
msgid "CPU frequency"
msgstr "CPU 频率"
msgid "RAM frequency"
msgstr "RAM 频率"
msgid "Flash Size"
msgstr "闪存大小"
msgid "Free Memory"
msgstr "释放内存"
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "ZRam Settings"
msgstr "ZRam 设置"
msgid "ZRam Compression Algorithm"
msgstr "ZRam 压缩算法"
msgid "ZRam Compression Streams"
msgstr "ZRam 压缩数据流线程数"
msgid "ZRam Size"
msgstr "ZRam 大小"
msgid "Size of the ZRam device in megabytes"
msgstr "划分给 ZRam 分区的内存大小MB推荐留空由系统自动管理"
msgid "Number of parallel threads used for compression"
msgstr "用于压缩内存数据的CPU并发线程数"
msgid "Swap"
msgstr "虚拟内存"
msgid "Swap used"
msgstr "已用交换区"
msgid "Force 40MHz mode"
msgstr "强制 40MHz 频宽"
msgid ""
"Always use 40MHz channels even if the secondary channel overlaps. Using this "
"option does not comply with IEEE 802.11n-2009!"
msgstr "强制启用 40MHz 频宽并忽略辅助信道重叠。此选项可能不兼容某些无线硬件导致无法启用!"
msgid "Disassociate On Low Acknowledgement"
msgstr "弱信号剔除"
msgid "Allow AP mode to disconnect STAs based on low ACK condition"
msgstr "允许 AP 模式基于低 ACK 条件判断剔除弱信号的客户端"
msgid "Running Status"
msgstr "运行状况"
msgid "Online Users"
msgstr "在线用户数"
msgid "DNS Redirect"
msgstr "DNS 重定向"
msgid "Redirect client DNS to dnsmasq"
msgstr "重定向客户端DNS到dnsmasq"
msgid "Enable 256-QAM"
msgstr "启用 256-QAM"
msgid "802.11n 2.4Ghz Only"
msgstr "只适合 802.11n 2.4Ghz"
msgid "Enables The 802.11k standard provides information to discover the best available access point"
msgstr "启用 802.11k 自动寻找发现最佳可用接入点的信息"
msgid "Enable neighbor report via radio measurements"
msgstr "启用无线电测量邻居报告"
msgid "Enable beacon report via radio measurements"
msgstr "启用无线电测量信标报告"
msgid "Enables 802.11v allows client devices to exchange information about the network topology,tating overall improvement of the wireless network."
msgstr "启用 802.11v 将允许客户端设备交换有关网络拓扑的信息,从而全面改善无线网络漫游"
msgid "extended sleep mode for stations"
msgstr "扩展无线休眠节能模式"
msgid "BSS Transition Management"
msgstr "BSS 传输管理"
msgid "UTC time at which the TSF timer is 0"
msgstr "TSF计时器为0的UTC时间"
msgid "Time advertisement"
msgstr "广播同步时间"
msgid "time zone"
msgstr "时区"
msgid "Local time zone as specified in 8.3 of IEEE Std 1003.1-2004"
msgstr "本地时区采用 IEEE Std 1003.1-2004 的 8.3 格式(例如 UTC8"
msgid "Custom Redirect Domain"
msgstr "自定义挟持域名"
msgid "Define a custom domain name and the corresponding PTR record"
msgstr "自定义域名对应的IP地址需要客户端DNS指向本路由"
msgid "Domain Name"
msgstr "域名(不带 HTTP(S)://"
msgid "Comments"
msgstr "备注"
msgid "Retain the current packages"
msgstr "保留已安装软件包"
msgid "Packet Steering"
msgstr "数据包引导"
msgid "Enable packet steering across all CPUs. May help or hinder network speed."
msgstr "启用所有CPU的数据包控制。 可能有助于或阻碍网络速度。"
msgid "Disable IPv6 DNS forwards"
msgstr "禁止解析 IPv6 DNS 记录"
msgid "Filter IPv6(AAAA) DNS Query Name Resolve"
msgstr "过滤掉 IPv6(AAAA) ,只返回 IPv4 DNS 域名记录"
msgid "Minimum TTL to send to clients"
msgstr "客户端缓存的最小 DNS TTL"
msgid "Modify DNS entries minimum TTL (max is 86400, 0 is no modify)"
msgstr "修改发送到客户端的域名记录的 TTL 时间 (最大 86400, 0 表示不修改)"
msgid "FullCone NAT"
msgstr "全锥形 NAT"
msgid "Using FullCone NAT can improve gaming performance effectively"
msgstr "使用全锥形 NAT 可以有效提升游戏体验"
msgid "Used space"
msgstr "已用空间"

View File

@ -1,15 +1,15 @@
#!/bin/sh /etc/rc.common
START=21
start() {
/usr/bin/fa-fancontrol.sh &
}
stop() {
kill -9 $(ps -w | grep fa-fancontrol | grep -v grep | awk '{print$1}') 2>/dev/null
}
restart() {
stop
start
}
#!/bin/sh /etc/rc.common
START=21
start() {
/usr/bin/fa-fancontrol.sh &
}
stop() {
kill -9 $(ps -w | grep fa-fancontrol | grep -v grep | awk '{print$1}') 2>/dev/null
}
restart() {
stop
start
}

View File

@ -1,69 +1,69 @@
#!/bin/bash
# determine fan controller
if [ -d /sys/devices/platform/pwm-fan ]; then
echo "pls use /usr/bin/fa-fancontrol.sh."
exit 1
fi
if [ ! -d /sys/class/pwm/pwmchip0 ]; then
echo "this model does not support pwm."
exit 1
fi
if [ ! -d /sys/class/pwm/pwmchip0/pwm0 ]; then
echo 0 > /sys/class/pwm/pwmchip0/export
fi
sleep 1
while [ ! -d /sys/class/pwm/pwmchip0/pwm0 ];
do
sleep 1
done
ISENABLE=`cat /sys/class/pwm/pwmchip0/pwm0/enable`
if [ $ISENABLE -eq 1 ]; then
echo 0 > /sys/class/pwm/pwmchip0/pwm0/enable
fi
echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
# max speed run 5s
echo 46990 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
sleep 5
echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
# declare -a CpuTemps=(55000 43000 38000 32000)
# declare -a PwmDutyCycles=(1000 20000 30000 45000)
declare -a CpuTemps=(75000 63000 58000 52000)
declare -a PwmDutyCycles=(25000 35000 45000 46990)
declare -a Percents=(100 75 50 25)
DefaultDuty=49990
DefaultPercents=0
while true
do
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
INDEX=0
FOUNDTEMP=0
DUTY=$DefaultDuty
PERCENT=$DefaultPercents
for i in 0 1 2 3; do
if [ $temp -gt ${CpuTemps[$i]} ]; then
INDEX=$i
FOUNDTEMP=1
break
fi
done
if [ ${FOUNDTEMP} == 1 ]; then
DUTY=${PwmDutyCycles[$i]}
PERCENT=${Percents[$i]}
fi
echo $DUTY > /sys/class/pwm/pwmchip0/pwm0/duty_cycle;
# echo "temp: $temp, duty: $DUTY, ${PERCENT}%"
# cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
sleep 2s;
done
#!/bin/bash
# determine fan controller
if [ -d /sys/devices/platform/pwm-fan ]; then
echo "pls use /usr/bin/fa-fancontrol.sh."
exit 1
fi
if [ ! -d /sys/class/pwm/pwmchip0 ]; then
echo "this model does not support pwm."
exit 1
fi
if [ ! -d /sys/class/pwm/pwmchip0/pwm0 ]; then
echo 0 > /sys/class/pwm/pwmchip0/export
fi
sleep 1
while [ ! -d /sys/class/pwm/pwmchip0/pwm0 ];
do
sleep 1
done
ISENABLE=`cat /sys/class/pwm/pwmchip0/pwm0/enable`
if [ $ISENABLE -eq 1 ]; then
echo 0 > /sys/class/pwm/pwmchip0/pwm0/enable
fi
echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
# max speed run 5s
echo 46990 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
sleep 5
echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
# declare -a CpuTemps=(55000 43000 38000 32000)
# declare -a PwmDutyCycles=(1000 20000 30000 45000)
declare -a CpuTemps=(75000 63000 58000 52000)
declare -a PwmDutyCycles=(25000 35000 45000 46990)
declare -a Percents=(100 75 50 25)
DefaultDuty=49990
DefaultPercents=0
while true
do
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
INDEX=0
FOUNDTEMP=0
DUTY=$DefaultDuty
PERCENT=$DefaultPercents
for i in 0 1 2 3; do
if [ $temp -gt ${CpuTemps[$i]} ]; then
INDEX=$i
FOUNDTEMP=1
break
fi
done
if [ ${FOUNDTEMP} == 1 ]; then
DUTY=${PwmDutyCycles[$i]}
PERCENT=${Percents[$i]}
fi
echo $DUTY > /sys/class/pwm/pwmchip0/pwm0/duty_cycle;
# echo "temp: $temp, duty: $DUTY, ${PERCENT}%"
# cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
sleep 2s;
done