fix(openwrt): use full opkg path and pre-check availability

`channel.exec()` doesn't source the shell profile, so PATH may not
include /usr/bin on some routers. Using /usr/bin/opkg explicitly
avoids exit-127 surprises. Added opkg_check() to give a clear error
("firmware may not support package management") before attempting
opkg_update, rather than a confusing "command not found" exit code.
Also split the BusyBox-hostile `grep -v 'all\|noarch'` into two
separate greps for the arch-detection fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 17:12:57 +00:00
co-authored by Claude Sonnet 4.6
parent 4c56e1bb96
commit bc1ec9aa3e
3 changed files with 19 additions and 6 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ pub fn install_tollgate(router: &Router) -> Result<()> {
// Package not in any feed — download the .ipk directly.
let arch = router
.run_ok("opkg print-architecture | grep -v 'all\\|noarch' | tail -1 | awk '{print $2}'")?;
.run_ok("/usr/bin/opkg print-architecture | grep -v all | grep -v noarch | tail -1 | awk '{print $2}'")?;
let arch = arch.trim();
let url = ipk_url(arch).ok_or_else(|| {
@@ -50,7 +50,7 @@ pub fn install_tollgate(router: &Router) -> Result<()> {
router.run_ok(&format!("wget -O /tmp/tollgate.ipk '{}'", url))?;
// Capture stderr too — BusyBox opkg exits 0 even on "Cannot install" failures.
let (out, _code) = router.run("opkg install --force-depends /tmp/tollgate.ipk 2>&1")?;
let (out, _code) = router.run("/usr/bin/opkg install --force-depends /tmp/tollgate.ipk 2>&1")?;
router.run_ok("rm -f /tmp/tollgate.ipk")?;
if out.contains("Cannot install") || out.contains("errors encountered") {
+1
View File
@@ -19,6 +19,7 @@ use crate::Router;
pub async fn provision(router: &Router, config: &TollGateConfig) -> Result<()> {
info!("[{}] Starting TollGate provisioning", router.host);
router.opkg_check()?;
router.opkg_update()?;
install_tollgate(router)?;
config::apply(router, config)?;