#!/bin/sh # act on wlan devices and broken events for qca proprietary devices which all have no DEVTYPE! [ "$DEVTYPE" = "wlan" ] || [ "$DEVTYPE${DEVICENAME%%[0-9]*}" = "wifi" ] || [ "$DEVTYPE${DEVICENAME%%[0-9]*}" = "ath" ] || exit 0 . /lib/config/uci.sh # uci_ lib works on temporary config files here which are not persistent UCI_CONFIG_DIR=/var/run CONFIG=plc-standby # create initial config file uci_set_default $CONFIG <<'EOF' config status 'status' option timeout '0' EOF [ "$DEVTYPE${DEVICENAME%%[0-9]*}" = "wifi" ] && exit 0 # check added/removed device if [ "$DEVTYPE" = "wlan" ]; then # strange behavior on ath9/10k! # on boot wlanX interface is added for all radios, then removed for radios without enabled interfaces, # but not for disabled radios. # ubus call not yet possible at this early boot stage. ignore this add when ubus fails. # or we could ignore the first added of a phy ubus call network.wireless status >/dev/null 2>&1 || exit fi devices=$(uci_get $CONFIG status wlandevs) case "$ACTION" in add) logger -t dlanx-standby "device $DEVICENAME added" devices="${devices//"$DEVICENAME "/}$DEVICENAME " uci_set $CONFIG status wlandevs "$devices" uci_commit $CONFIG ;; remove) logger -t dlanx-standby "device $DEVICENAME removed" devices="${devices//"$DEVICENAME "/}" uci_set $CONFIG status wlandevs "$devices" uci_commit $CONFIG ;; *) exit ;; esac