update 2024-03-06 20:00:54

This commit is contained in:
github-actions[bot]
2024-03-06 20:00:54 +08:00
parent 027424e8e3
commit 910711698e
7 changed files with 122 additions and 28 deletions

View File

@ -36,11 +36,13 @@ function index()
entry({ "admin", "system", "amlogic", "start_check_firmware" }, call("action_start_check_firmware")).leaf = true
entry({ "admin", "system", "amlogic", "start_check_plugin" }, call("action_start_check_plugin")).leaf = true
entry({ "admin", "system", "amlogic", "start_check_kernel" }, call("action_start_check_kernel")).leaf = true
entry({ "admin", "system", "amlogic", "start_check_rescue" }, call("action_start_check_rescue")).leaf = true
entry({ "admin", "system", "amlogic", "start_check_upfiles" }, call("action_start_check_upfiles")).leaf = true
entry({ "admin", "system", "amlogic", "start_amlogic_install" }, call("action_start_amlogic_install")).leaf = true
entry({ "admin", "system", "amlogic", "start_amlogic_update" }, call("action_start_amlogic_update")).leaf = true
entry({ "admin", "system", "amlogic", "start_amlogic_kernel" }, call("action_start_amlogic_kernel")).leaf = true
entry({ "admin", "system", "amlogic", "start_amlogic_plugin" }, call("action_start_amlogic_plugin")).leaf = true
entry({ "admin", "system", "amlogic", "start_amlogic_rescue" }, call("action_start_amlogic_rescue")).leaf = true
entry({ "admin", "system", "amlogic", "start_snapshot_delete" }, call("action_start_snapshot_delete")).leaf = true
entry({ "admin", "system", "amlogic", "start_snapshot_restore" }, call("action_start_snapshot_restore")).leaf = true
entry({ "admin", "system", "amlogic", "start_snapshot_list" }, call("action_check_snapshot")).leaf = true
@ -129,6 +131,7 @@ function action_refresh_log()
luci.sys.exec("echo '' > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
luci.sys.exec("echo '' > /tmp/amlogic/amlogic_check_kernel.log && sync >/dev/null 2>&1")
luci.sys.exec("echo '' > /tmp/amlogic/amlogic_check_firmware.log && sync >/dev/null 2>&1")
luci.sys.exec("echo '' > /tmp/amlogic/amlogic_check_rescue.log && sync >/dev/null 2>&1")
luci.sys.exec("echo '' > /tmp/amlogic/amlogic_running_script.log && sync >/dev/null 2>&1")
end
luci.http.prepare_content("text/plain; charset=utf-8")
@ -147,16 +150,17 @@ function action_del_log()
luci.sys.exec(": > /tmp/amlogic/amlogic_check_plugin.log")
luci.sys.exec(": > /tmp/amlogic/amlogic_check_kernel.log")
luci.sys.exec(": > /tmp/amlogic/amlogic_check_firmware.log")
luci.sys.exec(": > /tmp/amlogic/amlogic_check_rescue.log")
luci.sys.exec(": > /tmp/amlogic/amlogic_running_script.log")
end
--Upgrade luci-app-amlogic plugin
function start_amlogic_plugin()
luci.sys.call("echo '1@Plugin update in progress, try again later!' > /tmp/amlogic/amlogic_running_script.log && sync >/dev/null 2>&1")
local ipk_state = luci.sys.call("[ -f /etc/config/amlogic ] && cp -vf /etc/config/amlogic /etc/config/amlogic_bak > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
local ipk_state = luci.sys.call("opkg --force-reinstall install /tmp/amlogic/*.ipk > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
local ipk_state = luci.sys.call("[ -f /etc/config/amlogic_bak ] && cp -vf /etc/config/amlogic_bak /etc/config/amlogic > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
local ipk_state = luci.sys.call("rm -rf /tmp/luci-indexcache /tmp/luci-modulecache/* /etc/config/amlogic_bak >/dev/null 2>&1")
luci.sys.call("[ -f /etc/config/amlogic ] && cp -vf /etc/config/amlogic /etc/config/amlogic_bak > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
luci.sys.call("opkg --force-reinstall install /tmp/amlogic/*.ipk > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
luci.sys.call("[ -f /etc/config/amlogic_bak ] && cp -vf /etc/config/amlogic_bak /etc/config/amlogic > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
luci.sys.call("rm -rf /tmp/luci-indexcache /tmp/luci-modulecache/* /etc/config/amlogic_bak >/dev/null 2>&1")
luci.sys.call("echo '' > /tmp/amlogic/amlogic_running_script.log && sync >/dev/null 2>&1")
local state = luci.sys.call("echo 'Successful Update' > /tmp/amlogic/amlogic_check_plugin.log && sync >/dev/null 2>&1")
return state
@ -184,6 +188,15 @@ function start_amlogic_update()
return state
end
--Read rescue kernel log
local function start_amlogic_rescue()
luci.sys.call("echo '4@Kernel rescue in progress, try again later!' > /tmp/amlogic/amlogic_running_script.log && sync >/dev/null 2>&1")
luci.sys.call("chmod +x /usr/sbin/" .. device_kernel_script .. " >/dev/null 2>&1")
local state = luci.sys.call("/usr/sbin/" .. device_kernel_script .. " -s > /tmp/amlogic/amlogic_check_rescue.log && sync >/dev/null 2>&1")
luci.sys.call("echo '' > /tmp/amlogic/amlogic_running_script.log && sync >/dev/null 2>&1")
return state
end
--Install amlogic openwrt firmware
function start_amlogic_install()
luci.sys.exec("chmod +x /usr/sbin/" .. device_install_script .. " >/dev/null 2>&1")
@ -280,6 +293,11 @@ local function start_check_firmware()
return luci.sys.exec("sed -n '$p' /tmp/amlogic/amlogic_check_firmware.log 2>/dev/null")
end
--Read rescue kernel log
local function start_check_rescue()
return luci.sys.exec("sed -n '$p' /tmp/amlogic/amlogic_check_rescue.log 2>/dev/null")
end
--Read openwrt install log
local function start_check_install()
return luci.sys.exec("sed -n '$p' /tmp/amlogic/amlogic_check_install.log 2>/dev/null")
@ -309,6 +327,14 @@ function action_start_check_firmware()
})
end
--Return online check rescue kernel result
function action_start_check_rescue()
luci.http.prepare_content("application/json")
luci.http.write_json({
start_check_rescue = start_check_rescue();
})
end
--Return online install openwrt result
function action_start_check_install()
luci.http.prepare_content("application/json")
@ -365,6 +391,14 @@ function action_start_amlogic_plugin()
})
end
--Return rescue kernel result
function action_start_amlogic_rescue()
luci.http.prepare_content("application/json")
luci.http.write_json({
start_amlogic_rescue = start_amlogic_rescue();
})
end
--Return files upload result
function action_start_check_upfiles()
luci.http.prepare_content("application/json")

View File

@ -1,4 +1,4 @@
local b
local b, c
--SimpleForm for Check
b = SimpleForm("amlogic", nil)
@ -9,4 +9,14 @@ b.submit = false
b:section(SimpleSection).template = "amlogic/other_check"
return b
--SimpleForm for Rescue Kernel
c = SimpleForm("rescue", nil)
c.title = translate("Rescue Kernel")
c.description = translate("When a kernel update fails and causes the OpenWrt system to be unbootable, the kernel can be restored by mutual recovery from eMMC/NVMe/sdX.")
c.reset = false
c.submit = false
c:section(SimpleSection).template = "amlogic/other_rescue"
return b, c

View File

@ -215,7 +215,7 @@
_current_firmware_version.innerHTML = status.current_firmware_version ? "<font color=green><%:Current Version%> [ "+status.current_firmware_version+" ] </font>" : "<font color=red>"+"<%:Invalid value.%>"+"</font>";
_current_plugin_version.innerHTML = status.current_plugin_version ? "<font color=green><%:Current Version%> [ "+status.current_plugin_version+" ] </font>" : "<font color=red>"+"<%:Invalid value.%>"+"</font>";
_current_kernel_version.innerHTML = status.current_kernel_version ? "<font color=green><%:Current Version%> [ "+status.current_kernel_version+" ] </font>" : "<font color=red>"+"<%:Invalid value.%>"+"</font>";
_openwrt_mainline_version.innerHTML = status.current_kernel_branch ? " [ "+status.current_kernel_branch+".*** ] " : "[ "+"<%:Invalid value.%>"+" ]";
_openwrt_mainline_version.innerHTML = status.current_kernel_branch ? " [ "+status.current_kernel_branch+".y ] " : "[ "+"<%:Invalid value.%>"+" ]";
}
});

View File

@ -0,0 +1,46 @@
<style>
.NewsTdHeight{ line-height: 20px; }
</style>
<fieldset class="cbi-section">
<table width="100%" class="NewsTdHeight">
<tr><td width="35%" align="right"><input type="button" class="cbi-button cbi-button-reload" value="<%:Rescue the original system kernel%>" onclick="return b_rescue_kernel(this)"/></td><td width="65%" align="left"><span id="_current_rescue_version"><%:Collecting data...%></span> <span id="_check_rescue"></span></td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
function b_rescue_kernel(btn)
{
btn.disabled = true;
btn.value = '<%:Rescuing...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "system", "amlogic", "start_amlogic_rescue")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:Rescue the original system kernel%>';
}
else {
btn.disabled = false;
btn.value = '<%:Rescue the original system kernel%>';
}
return false;
});
}
var _check_rescue = document.getElementById('_check_rescue');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "system", "amlogic", "start_check_rescue")%>', status.start_check_rescue, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.start_check_rescue != "\n" && status.start_check_rescue != "" ) {
_check_rescue.innerHTML = '<font color="blue"> '+status.start_check_rescue+'</font>';
}
if ( status.start_check_rescue == "\n" || status.start_check_rescue == "" ) {
_check_rescue.innerHTML = '';
}
}
});
var _current_rescue_version = document.getElementById('_current_rescue_version');
XHR.get('<%=luci.dispatcher.build_url("admin", "system", "amlogic", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
_current_rescue_version.innerHTML = status.current_kernel_version ? "<font color=green><%:Current Version%> [ "+status.current_kernel_version+" ] </font>" : "<font color=red>"+"<%:Invalid value.%>"+"</font>";
}
});
//]]></script>