Trigger interface status

in my scenario I want to run a script when my device is not connected.

specifically, I use an GliNet device that extends my gateway ...

when the device is connected the wlan-sta virtual interface is activated and by executing the iw command the following result is obtained:

$iw wlan-sta info

Interface wlan-sta
        ifindex 12
        wdev 0x8
        addr e4:95:6e:aa:aa:aa
        ssid MYESSID
        type managed
        wiphy 0
        channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
        txpower 18.00 dBm

when the device is not connected, the interface does not exist (the iw command does not recognize wlan-sta as an interface, just as wlan-sta does not even appear in the output of ifconfig ...)

my question is: how can I insert a trigger that goes to perform operations (a trivial script) when wlan-sta is enabled / disabled?

I'd like to follow a best practice and not set up a crontab or use software that acts as a watcher ...

thank you for your support :smiling_face_with_three_hearts:

This is exactly what you want:

https://openwrt.org/docs/guide-user/base-system/hotplug#the_iface_folder