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

John kerry kerry9842 at gmail.com
Tue Sep 15 06:38:09 EDT 2015


Hi,

I have added following condition but its not working:

MYDEV='eth0'

if [ "$ACTION" = "pressed" -a "$BUTTON" = "BUT_2" ] && {
  devstatus "$MYDEV" | grep '"up": true' && {
    echo "255" >
/sys/devices/platform/leds-gpio/leds/db120:green:status/brightness
  }
}

fi

Am i doing any mistake or need to change anything

Regards,
John

On Tue, Sep 15, 2015 at 4:07 PM, Bastian Bittorf <bittorf at bluebottle.com>
wrote:

> * 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150915/206d9887/attachment.htm>
-------------- next part --------------
_______________________________________________
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