Gate the camera package check on the model, and migrate printers off the retired Entware feed host - #21
Open
arlophoenix wants to merge 1 commit into
Conversation
… host ensure_mjpg_streamer_packages tested /usr/bin/mjpg_streamer with no $model check, but only the K1 2025 camera services read /usr/bin and /usr/lib; the K1, 3V3, 3KE, 10SE and E5M services read /opt/bin and /opt/lib, which is Entware's territory. Split the function so each model is checked against the path its own service actually uses, and move the check ahead of the steps that disable the running streamer and copy the init script, so a failure leaves the printer as it was and hands control back to the menu instead of terminating helper.sh through the global set -e. Removing that path also removed both seds that rewrote /opt/etc/opkg.conf, and those seds were the only thing repairing printers still pointed at bin.tranducanh.com after that host stopped serving the repository. Replace them with a deliberate one-shot migration at startup that matches on the hostname so user-added feed lines survive, writes through a temp file so a full /opt image cannot truncate the config, and tells the user to run opkg update afterwards. Also stop install_entware reporting success unconditionally: it ran under set +e, symlinked /opt/libexec/sftp-server whether or not the install produced it, and printed a green checkmark either way. It also called prepare_opt, which was removed in 7a6ebfa and no longer exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ensure_mjpg_streamer_packagesdecides whether to install mjpg-streamer by testing/usr/bin/mjpg_streamer, with no$modelcheck, andinstall_usb_camerais wired into all six model menus. Only the K1 2025 camera services read/usr/binand/usr/lib; the K1, 3V3, 3KE, 10SE and E5M services read/opt/binand/opt/lib, which is Entware's territory, so on those five models the guard is testing a path their own service never looks at. This splits the check so each model is measured against the path it actually uses. Whether any legacy firmware ships/usr/bin/mjpg_streamerand therefore hits this in practice is not something I can check without that hardware, so this is a correctness fix rather than a reported bug.The same function's failure path was unsafe.
helper.shsets-eand sources every script into one shell, so areturn 1from a sourced function ends the whole program and drops the user to a prompt with no menu — and by the time the check ran, the working Entware streamer had already been stopped and renamed and the init script already copied into place, with nothing left running to undo any of it. The check now runs before anything destructive and its status is handled at both call sites, so a failure reports the reason and returns to the menu with the printer in the state it started in.Removing that path also removed both
seds that rewrote/opt/etc/opkg.conf, and those seds were the only thing still repairing printers left pointing atbin.tranducanh.comafter that host stopped serving the repository. Since/opt/etc/opkg.conflives on the printer's persistent/optand no helper-script update touches it, those printers would have been stranded with no way back. In their place is a deliberate one-shot migration at startup: it matches on the hostname rather than a line number so anything the user added to the file survives, writes through a temp file and only swaps it in once complete so a full/optimage cannot leave a truncated config behind, and prints a one-time notice namingopkg updateas the follow-up, since rewriting the config does not refresh a package index from March 2024. It cannot fail the script.Finally,
install_entwareran its whole body underset +eand then printed a green checkmark regardless of the outcome, symlinking/opt/libexec/sftp-serverwhether or not the install had produced it — so a failed install reported success and left SFTP broken behind a dangling symlink. It now checks that the install produced what the rest of the script depends on before saying so, and guards the symlink the same way theS48entwareboot script it writes already does. Theprepare_optcall in that function was removed in 7a6ebfa and has not existed since; it was harmless, becausefiles/entware/generic.shcreates the same directories, butset +ewas hiding acommand not foundon every legacy install.These four changes have to land together. The first two delete the seds, and the third is what replaces them.
Test plan
shellcheck -s bash -S warning -e SC2154,SC2034,SC1090,SC1091,SC1111on the three changed files introduces no new findings (the three that remain are pre-existing: the duplicated1080pcase pattern and one SC2155 inhelper.sh)bash -nparses every script in the repohelper.shstill running, leavesS96mjpg-streamerenabled, and runs no destructive step first; the legacy path issues exactly oneopkg updateand one package install;usb_camera.shno longer referencesopkg.confon any pathsrc/gzand non-feed directives verbatim, stays silent when there is nothing to do, and is a no-op on second runThe harness above is a local scratch script, not part of this PR; a test directory is a separate change.
Manual test pass
head -1 /opt/etc/opkg.confreadsbin.entware.netboth before and after a USB camera install/usr/bin/mjpg_streamer, run a USB camera install, and confirm you land back in the helper menu rather than a shell prompt/opt/etc/init.d/S96mjpg-streameris still enabled and/opt/etc/opkg.confis unchanged/usr/bin/mjpg_streamer, install the built-in camera fix, and confirm the stream comes up in Fluiddbin.tranducanh.com, launch the helper and confirm the notice appears once, the config is rewritten, and the notice does not return on the next launchls -l /usr/libexec/sftp-serverresolves to a real file/opt/binNot addressed
The duplicated
1080p|1080pcase pattern that silently rejects1080P, and the plain-HTTP fallback infiles/entware/generic.shthat downloads and root-executesopkgfrom a third-party host, are both real but unrelated to this change and belong in their own PRs. The redundantdisable_entware_builtin_mjpg_streamercall ininstall_builtin_camerais left alone too — the shipped service redoes that work on every start anyway, and untangling it would widen this diff.