update 2024-03-06 17:41:20

This commit is contained in:
github-actions[bot] 2024-03-06 17:41:20 +08:00
parent a82289ebe0
commit 04e415eead
7 changed files with 122 additions and 28 deletions

View File

@ -16,7 +16,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-amlogic
PKG_VERSION:=3.1.221
PKG_VERSION:=3.1.222
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0 License

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>

View File

@ -449,6 +449,18 @@ msgstr "当前版本"
msgid "Latest Version"
msgstr "最新版本"
msgid "Rescue Kernel"
msgstr "救援内核"
msgid "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."
msgstr "当内核更新失败造成 OpenWrt 系统无法启动时,可以从 eMMC/NVME/sdX 相互恢复内核。"
msgid "Rescue the original system kernel"
msgstr "救援原系统内核"
msgid "Rescuing..."
msgstr "正在救援..."
msgid "Current Device:"
msgstr "当前设备:"

View File

@ -29,19 +29,11 @@ AUTO_MAINLINE_UBOOT="no"
# Set the release check file
release_file="/etc/flippy-openwrt-release"
#
# Set font color
STEPS="[\033[95m STEPS \033[0m]"
INFO="[\033[94m INFO \033[0m]"
SUCCESS="[\033[92m SUCCESS \033[0m]"
FINISH="[\033[93m FINISH \033[0m]"
PROMPT="[\033[93m PROMPT \033[0m]"
ERROR="[\033[91m ERROR \033[0m]"
#
#====================================================================================
# Encountered a serious error, abort the script execution
error_msg() {
echo -e "[\033[1;91m Error \033[0m] ${1}"
echo -e "[Error] ${1}"
exit 1
}
@ -121,7 +113,7 @@ init_var() {
# Current device model
MYDEVICE_NAME="$(cat /proc/device-tree/model | tr -d '\000')"
[[ "${PLATFORM}" == "qemu-aarch64" ]] && MYDEVICE_NAME="KVM Virtual Machine"
echo -e "${INFO} Current device: ${MYDEVICE_NAME} [ ${PLATFORM} ], Use in [ ${EMMC_NAME} ]"
echo -e "Current device: ${MYDEVICE_NAME} [ ${PLATFORM} ], Use in [ ${EMMC_NAME} ]"
sync && echo ""
}
@ -354,7 +346,7 @@ update_uboot() {
# Rescue the kernel
sos_kernel() {
echo -e "${STEPS} Start rescuing kernel..."
echo -e "Start rescuing kernel..."
# Supports specifying disks, such as: [ openwrt-kernel -s mmcblk1 ]
box_disk="${2}"
@ -369,7 +361,7 @@ sos_kernel() {
# Check if the disk is the same as the current system disk
[[ "${box_disk}" == "${EMMC_NAME}" ]] && error_msg "The specified disk [ ${box_disk} ] is the same as the current system disk [ ${EMMC_NAME} ]."
echo -e "${INFO} The device name of the specified disk: [ ${box_disk} ]"
echo -e "The device name of the specified disk: [ ${box_disk} ]"
else
# Find emmc disk, first find emmc containing boot0 partition
box_disk="$(lsblk -l -o NAME | grep -oE '(mmcblk[0-9]?|nvme[0-9]?n[0-9]?|[hsv]d[a-z])' | grep -vE ^${EMMC_NAME} | sort -u | head -n 1)"
@ -377,11 +369,11 @@ sos_kernel() {
# Check if disk exists
[[ -z "${box_disk}" ]] && error_msg "Unable to locate the storage requiring rescue."
echo -e "${INFO} The device name of the target disk: [ ${box_disk} ]"
echo -e "The device name of the target disk: [ ${box_disk} ]"
fi
rescue_disk="/dev/${box_disk}"
echo -e "${INFO} The current OpenWrt is running on [ /dev/${EMMC_NAME} ], and the target disk for restoration is [ ${rescue_disk} ]."
echo -e "The current OpenWrt is running on [ /dev/${EMMC_NAME} ], and the target disk for restoration is [ ${rescue_disk} ]."
# Create a temporary mount directory
umount ${P4_PATH}/bootfs 2>/dev/null
@ -394,7 +386,7 @@ sos_kernel() {
[[ "${box_disk}" =~ ^([hsv]d[a-z]) ]] && rescue_disk_partition_name="" || rescue_disk_partition_name="p"
mount ${rescue_disk}${rescue_disk_partition_name}1 ${P4_PATH}/bootfs
[[ "${?}" -ne "0" ]] && error_msg "mount ${rescue_disk}${PARTITION_NAME}1 failed!"
echo -e "${INFO} The [ ${rescue_disk}${rescue_disk_partition_name}1 ] partition is mounted on [ ${P4_PATH}/bootfs ]."
echo -e "The [ ${rescue_disk}${rescue_disk_partition_name}1 ] partition is mounted on [ ${P4_PATH}/bootfs ]."
# Search uuid file
if [[ -f "${P4_PATH}/bootfs/uEnv.txt" ]]; then
@ -416,7 +408,7 @@ sos_kernel() {
# Mount target rootfs partition
mount ${target_rootfs} ${P4_PATH}/rootfs
[[ "${?}" -ne "0" ]] && error_msg "mount ${rescue_disk}${PARTITION_NAME}2 failed!"
echo -e "${INFO} The [ ${target_rootfs} ] partition is mounted on [ ${P4_PATH}/rootfs ]."
echo -e "The [ ${target_rootfs} ] partition is mounted on [ ${P4_PATH}/rootfs ]."
# Identify the current kernel files
kernel_signature="$(uname -r)"
@ -432,7 +424,7 @@ sos_kernel() {
}
cp -rf /boot/{*-${kernel_signature},uInitrd,*Image,dtb} .
[[ "${?}" -ne "0" ]] && error_msg "(1/2) [ boot ] kernel files rescue failed."
echo -e "${INFO} (1/2) [ boot ] kernel files rescue succeeded."
echo -e "(1/2) [ boot ] kernel files rescue succeeded."
} || error_msg "(1/2) The [ ${P4_PATH}/bootfs ] folder does not exist, stop rescuing."
# 02. For /lib/modules/${kernel_signature}
@ -441,7 +433,7 @@ sos_kernel() {
rm -rf *
cp -rf /lib/modules/${kernel_signature} .
[[ "${?}" -ne "0" ]] && error_msg "(2/2) [ modules ] kernel files rescue failed."
echo -e "${INFO} (2/2) [ modules ] kernel files rescue succeeded."
echo -e "(2/2) [ modules ] kernel files rescue succeeded."
} || error_msg "(2/2) The [ ${P4_PATH}/rootfs/lib/modules ] folder does not exist, stop rescuing."
# Unmount the emmc partition
@ -456,7 +448,7 @@ sos_kernel() {
sync && echo ""
}
echo -e "${STEPS} Welcome to the OpenWrt Kernel Management Tool."
echo -e "Welcome to the OpenWrt Kernel Management Tool."
# Operation environment check
[[ -x "/usr/sbin/openwrt-kernel" ]] || error_msg "Please grant execution permission: chmod +x /usr/sbin/openwrt-kernel"
@ -469,7 +461,7 @@ if [[ "${@}" =~ ^-s(\s)* ]]; then
# Kernel restore successful
sync && sleep 3
echo -e "${SUCCESS} Kernel rescue successful, please remove the disk and restart the OpenWrt system."
echo -e "Kernel rescue successful, please remove the disk and restart the OpenWrt system."
exit 0
else
# Initialize all variables