diff --git a/luci-app-amlogic/Makefile b/luci-app-amlogic/Makefile index 241e4489..d7557d47 100644 --- a/luci-app-amlogic/Makefile +++ b/luci-app-amlogic/Makefile @@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-amlogic -PKG_VERSION:=3.1.108 +PKG_VERSION:=3.1.110 PKG_RELEASE:=1 PKG_LICENSE:=GPL-2.0 License diff --git a/luci-app-amlogic/htdocs/luci-static/resources/amlogic/switch.png b/luci-app-amlogic/htdocs/luci-static/resources/amlogic/switch.png new file mode 100644 index 00000000..2a3577a9 Binary files /dev/null and b/luci-app-amlogic/htdocs/luci-static/resources/amlogic/switch.png differ diff --git a/luci-app-amlogic/luasrc/controller/amlogic.lua b/luci-app-amlogic/luasrc/controller/amlogic.lua index eb2c8701..6288ef7d 100644 --- a/luci-app-amlogic/luasrc/controller/amlogic.lua +++ b/luci-app-amlogic/luasrc/controller/amlogic.lua @@ -44,6 +44,7 @@ function index() entry({ "admin", "system", "amlogic", "start_openwrt_author" }, call("action_openwrt_author")).leaf = true entry({ "admin", "system", "amlogic", "state" }, call("action_state")).leaf = true entry({ "admin", "system", "amlogic", "start_poweroff" }, call("action_poweroff")).leaf = true + entry({ "admin", "system", "amlogic", "start_switch" }, call("action_switch")).leaf = true end --Remove the spaces in the string @@ -450,3 +451,10 @@ end function action_poweroff() luci.sys.exec("/sbin/poweroff") end + +--Switching dual partition +function action_switch() + luci.sys.exec("[ -f /boot/efi/EFI/BOOT/grub.cfg.prev ] && (cd /boot/efi/EFI/BOOT/ && mv -f grub.cfg grub.cfg.bak && mv -f grub.cfg.prev grub.cfg && mv -f grub.cfg.bak grub.cfg.prev)") + luci.sys.exec("sync && reboot") +end + diff --git a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua index 9a232a36..a3a008c9 100644 --- a/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua +++ b/luci-app-amlogic/luasrc/model/cbi/amlogic/amlogic_backup.lua @@ -5,13 +5,20 @@ local io = require "io" local os = require "os" local fs = require "nixio.fs" -local b, c +local b, c, x -- Checks wheather the given path exists and points to a directory. function isdirectory(dirname) return fs.stat(dirname, "type") == "dir" end +-- Check if a file or directory exists +function file_exists(path) + local file = io.open(path, "rb") + if file then file:close() end + return file ~= nil +end + --SimpleForm for Backup Config b = SimpleForm("backup", nil) b.title = translate("Backup Firmware Config") @@ -90,10 +97,22 @@ w.render = function(self, section, scope) end w.write = function(self, section, scope) - local x = luci.sys.exec("btrfs subvolume snapshot -r /etc /.snapshots/etc-" .. os.date("%m.%d.%H%M%S") .. " 2>/dev/null && sync") + local x = luci.sys.exec("btrfs subvolume snapshot -r /etc /.snapshots/etc-" .. + os.date("%m.%d.%H%M%S") .. " 2>/dev/null && sync") luci.http.redirect(luci.dispatcher.build_url("admin", "system", "amlogic", "backup")) end w = d:option(TextValue, "snapshot_list", nil) w.template = "amlogic/other_snapshot" -return b, c +--KVM virtual machine switching dual partition +if file_exists("/boot/efi/EFI/BOOT/grub.cfg.prev") then + x = SimpleForm("kvm", nil) + x.title = translate("KVM dual system switching") + x.description = translate("You can freely switch between KVM dual partitions, using OpenWrt systems in different partitions.") + x.reset = false + x.submit = false + + x:section(SimpleSection).template = "amlogic/other_kvm" +end + +return b, c, x diff --git a/luci-app-amlogic/luasrc/view/amlogic/other_kvm.htm b/luci-app-amlogic/luasrc/view/amlogic/other_kvm.htm new file mode 100644 index 00000000..710fe55d --- /dev/null +++ b/luci-app-amlogic/luasrc/view/amlogic/other_kvm.htm @@ -0,0 +1,48 @@ + +
+ + +
+ +

+ <%:Loading%> + + <%:System is switching...%> +

+
+
+ + diff --git a/luci-app-amlogic/po/zh-cn/amlogic.po b/luci-app-amlogic/po/zh-cn/amlogic.po index dca27d51..fe2881d3 100644 --- a/luci-app-amlogic/po/zh-cn/amlogic.po +++ b/luci-app-amlogic/po/zh-cn/amlogic.po @@ -284,6 +284,27 @@ msgstr "瑞芯微 3328 -- [ 贝壳云、我家云 ]" msgid "Used in KVM ----- [ Can be used in KVM virtual machine of Armbian system. ]" msgstr "KVM 中使用 --- [ 可以在 Armbia 系统的 KVM 虚拟机中使用。 ]" +msgid "KVM dual system switching" +msgstr "KVM 双系统切换" + +msgid "You can freely switch between KVM dual partitions, using OpenWrt systems in different partitions." +msgstr "您可以在 KVM 双分区之间自由切换,使用不同分区中的 OpenWrt 系统。" + +msgid "Switch System" +msgstr "切换系统" + +msgid "System is switching..." +msgstr "系统切换中..." + +msgid "Waiting for system switching..." +msgstr "等待系统完成切换..." + +msgid "System switchover succeeded, restarting..." +msgstr "系统切换成功,正在重启..." + +msgid "Are you sure you want to switch systems?" +msgstr "你确定要切换系统吗?" + msgid "Install Ipk" msgstr "安装Ipk" diff --git a/luci-app-amlogic/root/usr/sbin/openwrt-backup b/luci-app-amlogic/root/usr/sbin/openwrt-backup index 50ae9ed1..e0658c48 100755 --- a/luci-app-amlogic/root/usr/sbin/openwrt-backup +++ b/luci-app-amlogic/root/usr/sbin/openwrt-backup @@ -5,7 +5,7 @@ # Copyright (C) 2021-- https://github.com/ophub/luci-app-amlogic #====================================================================== -VERSION="v1.2" +VERSION="v1.3" ZSTD_LEVEL=6 SNAPSHOT_PRESTR=".snapshots/" BACKUP_DIR="/.reserved" @@ -81,8 +81,13 @@ elif dmesg | grep 'rockchip' >/dev/null 2>&1; then elif dmesg | grep 'sun50i-h6' >/dev/null 2>&1; then PLATFORM="allwinner" else - echo "Unknown platform, only support amlogic or rockchip or allwinner h6!" - exit 1 + source /etc/flippy-openwrt-release + case $PLATFORM in + amlogic|rockchip|allwinner|qemu-aarch64) : ;; + *) echo "Unknown platform, only support amlogic or rockchip or allwinner h6 or qemu-aarch64!" + exit 1 + ;; + esac fi backup() {