OpenWrt BusyBox Shell Constraints
Shell Feature Limitations
BusyBox ash does NOT support
set -o pipefail. NEVER add pipefail toansible.builtin.rawtasks or{{ openwrt_ssh }}commands that run on OpenWrt. Pipefail is required for all host-sideansible.builtin.shelltasks — see theproxmox-safetyrule.BusyBox
tr -d '[:space:]'deletes colons (:) because BusyBox treats[:space:]as a character set containing[,:,s,p,a,c,e,]— NOT as a POSIX character class. ALWAYS use explicit chars:tr -d ' \t\n\r'.BusyBox
ncdoes NOT support-w(timeout) flag. Use(echo QUIT | nc HOST PORT) </dev/nullfor TCP port checks. NEVER useecho | nc -w 3on OpenWrt.
Network Command Limitations
BusyBox
ip neigh showdoes NOT support IP filter arguments like full iproute2. ALWAYS use/proc/net/arpwithawkto look up gateway MACs on OpenWrt.Similarly, avoid
ip -o,grep -oP, andgrep -Eon OpenWrt.
Default Route Detection
- When checking for the default route in scripts on OpenWrt, NEVER filter by device name (
ip route show default dev eth0). OpenWrt's netifd may use interface aliases (e.g.,wan,eth0.2) that differ from the physical device name. Useip route show defaultwithout a device filter.
Process Detection
NEVER use
pgrepon OpenWrt — it may not exist in BusyBox. Use/etc/init.d/<service> statusorps | grep -c '[p]rocess'instead.Previous bug:
pgrep -x logdfailed on OpenWrt because pgrep wasn't available. Fixed by using/etc/init.d/log status.