Triggering script on kernel event for cable plugged in to LAN/WAN port

Great suggestion, thank you! I will implement it this way.

EDIT: came up with the following script, started in background very early in an init.d script.

#!/usr/bin/awk -f

/rt3050-esw [^ ]* link changed 0x00/ { \
    system( "ubus call network.interface.lan down; \
         ubus call network.interface.wan down") }
/rt3050-esw [^ ]* link changed 0x01/ { \
    system( "ubus call network.interface.lan down; \
         ubus call network.interface.wan up" ) }
/rt3050-esw [^ ]* link changed 0x02/ { \
    system( "ubus call network.interface.lan up; \
         ubus call network.interface.wan down" ) }
/rt3050-esw [^ ]* link changed 0x03/ { \
    system( "ubus call network.interface.lan up; \
         ubus call network.interface.wan up" ) }
1 Like