From fd4d83ea0e41b0a71d93a494cfec8a6075967fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdurrahman=20Kaan=20Dike=C3=A7?= Date: Mon, 5 Oct 2026 02:12:33 +0300 Subject: [PATCH] vendor-overlay, reset-password: the third system; the uninstallers stay system-agnostic Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn --- rootfs/overlay/opt/mu300/bin/mu300-os | 2 +- tests/test_static.py | 23 +++++++++++++++++++++++ tools/reset-password.sh | 13 +++++++------ tools/vendor-overlay.py | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/rootfs/overlay/opt/mu300/bin/mu300-os b/rootfs/overlay/opt/mu300/bin/mu300-os index 8d594784..396aef07 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-os +++ b/rootfs/overlay/opt/mu300/bin/mu300-os @@ -1,6 +1,6 @@ #!/bin/sh # Choose which system on the Linux disk area boots next. Any directory with an /etc and an init counts, so -# ubuntu, openwrt, immortalwrt, arch, debian, kali ... all work the same way. +# ubuntu, openwrt, openwrt-luci, immortalwrt, arch, debian, kali ... all work the same way. # mu300-os show installed systems and the current choice # mu300-os boot that system from now on (reboot to apply) # OpenWrt: od/timeout come from the static busybox in /opt/mu300/busybox-bin diff --git a/tests/test_static.py b/tests/test_static.py index 67fb703c..fda16916 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -103,6 +103,29 @@ class Rules(unittest.TestCase): for f in ('uninstall.sh', 'uninstall.ps1', 'tools/reset-password.sh', 'tools/android-import-hotspot.sh'): self.assertIn('mu300sd', (TOP / f).read_text(), f) + def test_every_system_list_has_openwrt_luci(self): + # every place that names the systems knows the third one, by its name or by the OpenWrt kind pattern + files = ('boot/init', 'rootfs/overlay/opt/mu300/bin/mu300-update', 'rootfs/overlay/opt/mu300/bin/mu300-os', + 'tools/android-install.sh', 'tools/reset-password.sh', 'tools/vendor-overlay.py', 'install.sh', + 'install.ps1', 'tools/make-release.sh') + for f in files: + with self.subTest(file=f): + # each skip is lifted alone by the task that gives its file the third system + if f == 'install.sh': + self.skipTest('install.sh: until Task 6') + if f == 'install.ps1': + self.skipTest('install.ps1: until Task 7') + if f == 'tools/make-release.sh': + self.skipTest('tools/make-release.sh: until Task 11') + text = (TOP / f).read_text() + self.assertTrue('openwrt-luci' in text or 'openwrt-*' in text or 'openwrt|openwrt-' in text, f) + + def test_uninstallers_have_no_per_system_list(self): + # they remove the whole Linux filesystem; a per-system case arm added later would forget the third name + for f in ('uninstall.sh', 'uninstall.ps1'): + text = (TOP / f).read_text() + self.assertNotRegex(text, r'(^|\s)(ubuntu|openwrt)\)', f) + def test_init_finds_partitions_after_the_modules(self): # the eMMC driver is one of the vendor modules: misc and boot_b cannot be found before they are loaded init = (TOP / 'boot' / 'init').read_text() diff --git a/tools/reset-password.sh b/tools/reset-password.sh index 43a91571..924d2e4e 100755 --- a/tools/reset-password.sh +++ b/tools/reset-password.sh @@ -3,12 +3,13 @@ # (adb + su); it mounts the Linux filesystem from Android and rewrites the password hash in /etc/shadow. With an # installation on the SD card (ext4 labelled mu300sd) that one is changed: it is the one that boots. # -# tools/reset-password.sh [ubuntu|openwrt|both] (default: both) +# tools/reset-password.sh [ubuntu|openwrt|openwrt-luci|all] (default: all; both is an alias of all) # # Forgot the password and Linux boots by default? Unplug the device about ten seconds after it powers on and plug # it back in: the bootloader sees an unfinished boot and falls back to Android, then run this. set -eu -WHICH=${1:-both} +WHICH=${1:-all} +[ "$WHICH" = both ] && WHICH=all TOP=$(cd "$(dirname "$0")/.." && pwd) T=/data/local/tmp @@ -19,7 +20,7 @@ su_do() { adb shell "su -c '$1'" /dev/null || die "adb not found" command -v python3 >/dev/null || die "python3 not found" . "$TOP/tools/linux-mode.sh" @@ -63,7 +64,7 @@ echo "$out" | grep -q '^MOUNTED' || die "could not mount the Linux filesystem ($ trap 'su_do "sync; sh '"$T"'/android-mount-mu300root.sh -u '"$T"'/mu300root" >/dev/null 2>&1 || true' EXIT systems=$WHICH -[ "$WHICH" = both ] && systems="ubuntu openwrt" +[ "$WHICH" = all ] && systems="ubuntu openwrt openwrt-luci" found= for os in $systems; do [ "$(su_do "[ -f $T/mu300root/$os/etc/shadow ] && echo y")" = y ] && found="$found $os" @@ -71,14 +72,14 @@ done [ -n "$found" ] || die "no installed system found on the Linux filesystem" echo " systems:$found" -printf 'New password for "ubuntu" (Ubuntu) and "root" (OpenWrt): ' +printf 'New password for "ubuntu" (Ubuntu) and "root" (OpenWrt, openwrt-luci): ' [ -t 0 ] && stty -echo; read -r pw1; printf '\nRepeat: '; read -r pw2; [ -t 0 ] && stty echo; echo [ "$pw1" = "$pw2" ] && [ ${#pw1} -ge 6 ] || die "passwords differ or are shorter than 6 characters" HASH=$(printf '%s\n' "$pw1" | python3 "$TOP/tools/sha512crypt.py") case $HASH in \$6\$*) ;; *) die "could not build the password hash" ;; esac for os in $found; do - case $os in ubuntu) user=ubuntu ;; openwrt) user=root ;; esac + case $os in ubuntu) user=ubuntu ;; openwrt|openwrt-*) user=root ;; esac # the hash contains $ and /, which the device shell would expand inside su -c: edit the file on this computer tmp=$(mktemp) adb shell "su -c 'cat $T/mu300root/$os/etc/shadow > /data/local/tmp/mu300-pull.bin'" /dev/null diff --git a/tools/vendor-overlay.py b/tools/vendor-overlay.py index 16f68673..6f41d056 100755 --- a/tools/vendor-overlay.py +++ b/tools/vendor-overlay.py @@ -132,7 +132,7 @@ def add_members(tar, src: Path, dest: str, seen: set, rename=None): def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - ap.add_argument('--os', required=True, choices=['ubuntu', 'openwrt']) + ap.add_argument('--os', required=True, choices=['ubuntu', 'openwrt', 'openwrt-luci']) ap.add_argument('--firmware', type=Path) ap.add_argument('--android-subset', type=Path, required=True) ap.add_argument('--gpu-subset', type=Path)