[OpenWrt-Devel] OpenWrt /etc/hotplug.d/button/00-wps

Bastian Bittorf bittorf at bluebottle.com
Tue Sep 15 04:07:52 EDT 2015


* John kerry <kerry9842 at gmail.com> [15.09.2015 08:52]:
> I have to write some condition in
> /etc/hotplug.d/button/50-wps/ file
> 
> I have to configure cat /etc/hotplug.d/button/00-wps file for following
> condition:
> if [ "$BUTTON" = "BTN_2" ] && [ "$ACTION" = "pressed" ]; then
> 
> I have to check eth0.1 if link is up then have ON status led otherwise OFF.

if i understand you correctly, you want this:

MYDEV='eth0.1'
[ "$BUTTON" = 'BTN_2' -a "$ACTION" = 'pressed' ] && {
  devstatus "$MYDEV" | grep '"up": true' && {
    your_action_here
  }
}

but this is at least...rude. better you use the correct
JSON-parser like:

. /usr/share/libubox/jshn.sh
json_load "$( devstatus eth0.1 )"
json_get_var 'JSON_VAR_up' 'up'
json_cleanup

in case your dev is up you have e.g.
$JSON_VAR_up = 1

bye, bastian
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list