mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-17 13:43:01 +08:00
update 2026-05-12 18:27:45
This commit is contained in:
1 parent
7f3005ed5a
commit
33be405a88
4 files changed
+64
-44
No files matched your search
@@ -92,6 +92,31 @@ function show_install_menu() {
|
||||
return m ? m[1] : 'Unknown';
|
||||
}
|
||||
|
||||
// Detect whether OpenWrt's root fs is on internal storage (eMMC/NVMe/fixed disk).
|
||||
// Returns true → already installed, hide the Install menu.
|
||||
// Returns false → running from USB/SD, show the Install menu.
|
||||
//
|
||||
// sd* devices can be either USB (removable=1) or internal SATA (removable=0);
|
||||
// we read /sys/block/<base_dev>/removable to distinguish them.
|
||||
// mmcblk* and nvme* are always internal storage on these platforms.
|
||||
function root_on_internal_storage() {
|
||||
const root_pt = trim(sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'"));
|
||||
if (!root_pt) return false;
|
||||
|
||||
if (match(root_pt, /^mmcblk[0-9]+p[0-9]+$/) || match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)) {
|
||||
// eMMC and NVMe are always internal
|
||||
return true;
|
||||
}
|
||||
if (match(root_pt, /^[hsv]d[a-z][0-9]+$/)) {
|
||||
// Strip trailing partition digit(s) to get base device (e.g. sda2 → sda)
|
||||
const base_dev = replace(root_pt, /[0-9]+$/, '');
|
||||
const removable = trim(sh('cat /sys/block/' + shq(base_dev) + '/removable 2>/dev/null'));
|
||||
// removable=0 → internal SATA/fixed disk; removable=1 → USB/removable
|
||||
return (removable == '0');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pick the helper script names for the current platform (as the original
|
||||
// controller did).
|
||||
function platform_scripts() {
|
||||
@@ -225,7 +250,8 @@ function m_state() {
|
||||
current_kernel_version: current_kernel_version(),
|
||||
current_kernel_branch: current_kernel_branch(),
|
||||
kernel_release: sh('uname -r'),
|
||||
has_luci_js: access('/www/luci-static/resources/luci.js') ? true : false
|
||||
has_luci_js: access('/www/luci-static/resources/luci.js') ? true : false,
|
||||
plugin_branch: access('/usr/lib/lua/luci/controller/amlogic.lua') ? 'lua' : 'main'
|
||||
};
|
||||
}
|
||||
|
||||
@@ -242,14 +268,10 @@ function m_platform_info() {
|
||||
const can_install = (index(p, 'amlogic') >= 0 || index(p, 'allwinner') >= 0 || index(m, 'yes') >= 0);
|
||||
// can_armcpu: all platforms except qemu support CPU frequency settings
|
||||
const can_armcpu = (index(p, 'qemu') < 0);
|
||||
// is_installed: root fs is on an internal storage device (mmcblk/sd/hd/vd),
|
||||
// meaning OpenWrt has already been installed to eMMC/NVMe/disk. When true,
|
||||
// the Install OpenWrt menu should be hidden.
|
||||
const root_pt = sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'");
|
||||
const is_installed = (root_pt != '' &&
|
||||
(match(root_pt, /^mmcblk[0-9]+p[1-4]$/) ||
|
||||
match(root_pt, /^[hsv]d[a-z][0-9]+$/) ||
|
||||
match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)));
|
||||
// is_installed: root fs is on an internal storage device (eMMC/NVMe/fixed disk).
|
||||
// sd* devices may be USB (removable=1) or internal SATA (removable=0); check
|
||||
// /sys/block/<dev>/removable to distinguish. When true the Install menu is hidden.
|
||||
const is_installed = root_on_internal_storage();
|
||||
return {
|
||||
platform: p,
|
||||
install_menu: m,
|
||||
@@ -719,11 +741,7 @@ function m_sync_menu() {
|
||||
const p = platform();
|
||||
const m = show_install_menu();
|
||||
// Detect whether OpenWrt has already been installed to internal storage
|
||||
const root_pt = sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'");
|
||||
const is_installed = (root_pt != '' &&
|
||||
(match(root_pt, /^mmcblk[0-9]+p[1-4]$/) ||
|
||||
match(root_pt, /^[hsv]d[a-z][0-9]+$/) ||
|
||||
match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)));
|
||||
const is_installed = root_on_internal_storage();
|
||||
const can_install = (index(p, 'amlogic') >= 0 || index(p, 'allwinner') >= 0 || index(m, 'yes') >= 0);
|
||||
const show_install = (can_install && !is_installed) ? 'yes' : 'no';
|
||||
const show_armcpu = (index(p, 'qemu') < 0) ? 'yes' : 'no';
|
||||
|
||||
Reference in new issue
Block a user