I want to trigger execution of a script when a cable is plugged in to the LAN or WAN port of my GL-MT300N-V2. OpenWrt 21.02.0.
hotplug script on iface/net - nothing happens. "ubus monitor", also no events listed.
logread -f on WAN plugged (for example):
Plugged: kern.info kernel: [ 5052.874092] rt3050-esw 10110000.esw: link changed 0x03
Unplugged: kern.info kernel: [ 5051.140355] rt3050-esw 10110000.esw: link changed 0x02
Polling the switch state would be possible, but is not favoured. I can get the status with "swconfig dev switch0 port 0 get link" for WAN; LAN is port 6.
Is there an event driven solution for this possible?
In our device, we must add hack to our setup. We are using simple script which sits on /dev/kmsg and is parsing every line. It is then easy to catch link changed 0x events and depending on the number, do proper action. We are then calling ubus call network.interface.lan "up" or "down" depending on the value.