Wan up/down /etc/hotplug.d/iface scripts not called/run

I have two scripts under /etc/hotplug.d/iface to play sounds thru the PC speaker when the WAN (pppoe-wan) interface goes up and down but they're not working.
What am I missing and do filename's matter?

root@apu:~# cat /etc/hotplug.d/iface/99-ifupwan 
#!/bin/sh
[ "$ACTION" = "ifup" -a "$INTERFACE" = "pppoe-wan" ] && {
    /usr/bin/beep -f 130 -l 100 -n -f 262 -l 100 -n -f 330 -l 100 -n -f 392 -l 100 -n -f 523 -l 100 -n -f 660 -l 100 -n -f 784 -l 300 -n -f 660 -l 300 -n -f 146 -l 100 -n
}
exit 0


root@apu:~# cat /etc/hotplug.d/iface/99-ifdownwan 
#!/bin/sh
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "pppoe-wan" ] && {
    n=3000; while [ $n -gt 400 ]; do /usr/bin/beep -f $n -l 5; n=$((n*97/100)); done
}
exit 0

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

@vgaetera Thanks, the script definitely isn't being called or run, I added /usr/bin/env > /tmp/envs_log.log to the 99-ifdownwan script and no log is created.

root@apu:~# cat /etc/hotplug.d/iface/99-ifdownwan 
#!/bin/sh
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "pppoe-wan" ] && {
    n=3000; while [ $n -gt 400 ]; do /usr/bin/beep -f $n -l 5; n=$((n*97/100)); done
    /usr/bin/env > /tmp/envs_log.log
}
exit 0

The interface name is correct, it is renamed before the PPPoE session is initiated:

root@apu:# ifconfig pppoe-wan
pppoe-wan Link encap:Point-to-Point Protocol  
          inet addr:xxx.207.209.186  P-t-P:xxx.207.208.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1440  Metric:1
          RX packets:31796 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19454 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:38444004 (36.6 MiB)  TX bytes:1625998 (1.5 MiB)

How do I troubleshoot the hotplug script not being called/run?

What have you tried out of:

?

Logging events would be step 1 in my book.

1 Like

The section under Troubleshooting has one tip about adding env > /tmp/envs_log.log to your script to view the variables as procd sees them. The rest of that page is descriptions of variables and script examples, unless I'm missing something?
As suggested I did add that line, but since the script isn't being called, env is never run and no log created. Which is what my Q alluded to.

Is there anything in logread when the script should be called?

What happens, if the following line is the only line in the hotplug-script?

/usr/bin/env > /tmp/envs_${INTERFACE}_${DEVICE}_log.log

1 Like

So here is what we use for sqm-scripts:

#!/bin/sh

[ -n "$DEVICE" ] || exit 0

restart_sqm() {
    /usr/lib/sqm/run.sh stop ${DEVICE}
    /usr/lib/sqm/run.sh start ${DEVICE}
}

[ "$ACTION" = ifup ] && /etc/init.d/sqm enabled && restart_sqm

[ "$ACTION" = ifdown ] && /usr/lib/sqm/run.sh stop ${DEVICE}

could it be that $INTERFACE is actually wan while $DEVICE is pppoe-wan?

Remove those:

Redundant.

It may break the loop which sources the scripts.

1 Like

Understandable mistake, though:

# grep '^#!/bin/sh' /etc/hotplug.d/*/* | sed 's-^-    -'
firmware/10-ath9k-eeprom:#!/bin/sh
firmware/11-ath10k-caldata:#!/bin/sh
ieee80211/00-wifi-migration:#!/bin/sh
ieee80211/10-wifi-detect:#!/bin/sh
iface/20-firewall:#!/bin/sh
net/00-sysctl:#!/bin/sh
net/20-smp-tune:#!/bin/sh
ntp/25-dnsmasqsec:#!/bin/sh

This is on current master

1 Like

Shebang is redundant for sourced scripts:

It might be some legacy code:

2 Likes

I'm aware of that. I was merely pointing out, that if OP used an existing script as a template, he might have fallen into that trap, because half of the distributed hotplug scripts on master have this superflouous line

1 Like

Fair enough, but this is not a show stopper, as the sqm-scripts hotlug script works like a charm.
My hunch is that for the OP "$INTERFACE" = "pppoe-wan" never evaluates true...

3 Likes

The issue was $INTERFACE = pppoe-wan instead of wan. kern.info kernel: [222085.546811] pppoe-wan: renamed from ppp0 in the log threw me off. ifup and ifdown also use pppoe-wan as the interface.

1 Like

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