diff options
author | Andre Heider <a.heider@gmail.com> | 2022-11-02 08:50:20 +0100 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2023-04-12 19:49:30 +0200 |
commit | 28e357d528edf5980a523eff497b72da8bde3d91 (patch) | |
tree | 326255e685402cd6b122a626c7568113c8fad16b /package/base-files/files | |
parent | 8fbe7738b9ef4131c8ca069c0f3abde134139da2 (diff) | |
download | upstream-28e357d528edf5980a523eff497b72da8bde3d91.tar.gz upstream-28e357d528edf5980a523eff497b72da8bde3d91.tar.bz2 upstream-28e357d528edf5980a523eff497b72da8bde3d91.zip |
base-files: add 'isup' to the wifi script
This is a silent command that allows easy wifi up/down automation for
scripts.
It takes one or multiple devices as arguments (or all if none are passed),
and the exit code indicates if any of those is not up.
E.g.:
wifi isup && echo "all wifi devices are up"
wifi isup radio0 || echo "this wifi is down"
Signed-off-by: Andre Heider <a.heider@gmail.com>
Diffstat (limited to 'package/base-files/files')
-rwxr-xr-x | package/base-files/files/sbin/wifi | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi index 29585389df..a3d3206ee7 100755 --- a/package/base-files/files/sbin/wifi +++ b/package/base-files/files/sbin/wifi @@ -6,7 +6,7 @@ usage() { cat <<EOF -Usage: $0 [config|up|down|reconf|reload|status] +Usage: $0 [config|up|down|reconf|reload|status|isup] enables (default), disables or configures devices not yet configured. EOF exit 1 @@ -21,6 +21,22 @@ ubus_wifi_cmd() { ubus call network.wireless "$cmd" "$(json_dump)" } +wifi_isup() { + local dev="$1" + + json_load "$(ubus_wifi_cmd "status" "$dev")" + json_get_keys devices + + for device in $devices; do + json_select "$device" + json_get_var up up + [ $up -eq 0 ] && return 1 + json_select .. + done + + return 0 +} + find_net_config() {( local vif="$1" local cfg @@ -245,6 +261,7 @@ case "$1" in detect) wifi_detect_notice ;; config) wifi_config ;; status) ubus_wifi_cmd "status" "$2";; + isup) wifi_isup "$2"; exit $?;; reload) wifi_reload "$2";; reload_legacy) wifi_reload_legacy "$2";; --help|help) usage;; |