Enable hotplug script

As I know, I can execute a script when I put a script in /etc/hotplug.d/~~
And I want to use it when I attach a device to the wlan.
So I put a test script in /etc/hotplug.d/ieee80211/00-my

#!/bin/sh
[ "${ACTION}" = "add" ] && {
        echo hello
}

but it never happen when I associate a new device.

When I just put

echo hello

and write a command "hotplug-call ieee80211" it works.
but ACTION Add deosnt work I guess.

How can I enable it?

Here is my system info.

root@OpenWrt-C50:/etc/hotplug.d/ieee80211# ubus call system board
{
        "kernel": "6.6.54",
        "hostname": "OpenWrt-C50",
        "system": "MediaTek MT7628AN ver:1 eco:2",
        "model": "TP-Link Archer C50 v3",
        "board_name": "tplink,archer-c50-v3",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "SNAPSHOT",
                "revision": "r27722-e00b6ba0c8",
                "target": "ramips/mt76x8",
                "description": "OpenWrt SNAPSHOT r27722-e00b6ba0c8"
        }
}
1 Like

Script has to go to a subdirectory...
https://openwrt.org/docs/guide-user/base-system/hotplug#how_it_works

1 Like

I am sorry, but
do you mean I didn't put my script on the right directory?

Yep, only that.
btw you can add logger $ACTION $DEVICE and similar to log what triggers the script and with what parameters.

Well, in the doc, "block", "button" ... are subdirectories of hotplug.
I knew it.
But there is a directory "ieee80211" in my hotplug.d folder.
And it is a default setting.
So I guess this is for wlan to detect some STAs or sth attached.

If it is wrong, can you tell guide me a hotplug which can detect wlan client?

Log the ACTION to see what events are generated?

Follow the troubleshooting section from the wiki. Use the script shown, trigger it, and it will log what environment variables are passed to each hotplug.d sub directory. https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting

@brada4
@RuralRoots

root@OpenWrt-C50:/etc/hotplug.d/iface# logread -e hotplug
Sun Nov 17 10:51:49 2024 kern.warn kernel: [    7.977972] gpio_button_hotplug: loading out-of-tree module taints kernel.
Sun Nov 17 10:52:13 2024 user.notice hotplug: USER=root ACTION=ifup SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=loopback PWD=/ DEVICE=lo
Sun Nov 17 10:52:15 2024 user.notice hotplug: USER=root ACTION=ifdown SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=lan PWD=/
Sun Nov 17 10:52:21 2024 user.notice hotplug: USER=root ACTION=ifup SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=lan PWD=/ DEVICE=br-lan

yeah.
hotplug.d/iface is working.
but nothing from hotplug.d/ieee80211

And I checked also "net" subdirectory.
But I couldn't get any clue.

Sun Nov 17 11:23:58 2024 kern.warn kernel: [    7.979539] gpio_button_hotplug: loading out-of-tree module taints kernel.
Sun Nov 17 11:24:21 2024 user.notice hotplug: USER=root ACTION=add SHLVL=1 HOME=/ SEQNUM=468 IFINDEX=4 HOTPLUG_TYPE=net DEVPATH=/devices/virtual/net/br-lan LOGNAME=root DEVICENAME=br-lan TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=br-lan PWD=/ DEVTYPE=bridge
Sun Nov 17 11:24:22 2024 user.notice hotplug: USER=root ACTION=add SHLVL=1 HOME=/ SEQNUM=470 IFINDEX=5 HOTPLUG_TYPE=net DEVPATH=/devices/virtual/net/eth0.1 LOGNAME=root DEVICENAME=eth0.1 TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=eth0.1 PWD=/ DEVTYPE=vlan
Sun Nov 17 11:24:22 2024 user.notice hotplug: USER=root ACTION=add SHLVL=1 HOME=/ SEQNUM=472 IFINDEX=6 HOTPLUG_TYPE=net DEVPATH=/devices/virtual/net/eth0.2 LOGNAME=root DEVICENAME=eth0.2 TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=eth0.2 PWD=/ DEVTYPE=vlan
Sun Nov 17 11:24:23 2024 user.notice hotplug: USER=root ACTION=ifup SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=loopback PWD=/ DEVICE=lo
Sun Nov 17 11:24:24 2024 user.notice hotplug: USER=root ACTION=ifdown SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=lan PWD=/
Sun Nov 17 11:24:31 2024 user.notice hotplug: USER=root ACTION=ifup SHLVL=1 HOME=/ HOTPLUG_TYPE=iface LOGNAME=root DEVICENAME= TERM=linux PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=lan PWD=/ DEVICE=br-lan
Sun Nov 17 11:24:36 2024 user.notice hotplug: USER=root ACTION=add SHLVL=1 HOME=/ SEQNUM=479 IFINDEX=7 HOTPLUG_TYPE=net DEVPATH=/devices/pci0000:00/0000:00:00.0/0000:01:00.0/net/phy1-ap0 LOGNAME=root DEVICENAME=phy1-ap0 TERM=linux SUBSYSTEM=net PATH=/usr/sbin:/usr/bin:/sbin:/bin INTERFACE=phy1-ap0 PWD=/ DEVTYPE=wlan

Maybe neigbour gets arp entry?

put logger in the neigh directory.
but irrelevant...

no more info about hotplug?
no materials, search..

Let system run for some time.

It seems that hotplug event is for WiFi devices, not clients. Not 100% sure.

Well, If my understanding is correct,
That's what I want.

The Wifi Device(AP) hotplug when client attach to the AP.

As it said

This patch moves the wifi configuration to hotplug scripts.
For mac80211, the wifi configuration will now automatically
run any time a "ieee80211" device is added. Likewise
broadcom-wl's script checks for new "net" devices which
have the "wl$NUMBER" moniker.

Well, but no response from hotplug.
I guessed if my phone attach to the AP Wifi, the script in ieee80211 executes.

New device like in usb or pci device, not STA, you can snap hostap log for associations, then dhcp log for IP. Note that MAC addresses may not always match.

Thank you for the reply.
I couldn't find answer from dhcp subdirectory.
Maybe what I want is not implemented yet.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.