Hi,
I have created the following script in hotplug.d/net to gracefully shutdown my router when eth0 link (wan) is down. My Openwrt router is powered by a battery, the aim is to have a proper shutdown of the system on power outage. However, when eth0 is down nothing happens... not even the logging part befor the conditional execution at the begining of the script. I heard that hotplug.d is not any more working and we need to use procd instead, is this true? If not, how can I make the scripts under hotplug.d/net work when network events are triggered?
#!/bin/sh
echo hotplug/net: $ACTION $INTERFACE >> /tmp/ups.log
logger -t hotplug "ups script $ACTION $INTERFACE"
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && {
logger -t hotplug "eth0 down - traced by ups.sh"
sleep 180
status=$(ifconfig eth0 | grep -E '(UP\sBROADCAST\sRUNNING\sMULTICAST)')
if [[ "$status" ]]; then
#echo "eth0 is UP"
logger "eth0 link restored - traced by ups.sh"
else
#echo "eth0 is DOWN"
logger -t hotplug "Halting system - traced by ups.sh"
poweroff
fi
}
The output of ps | grep hotplug is given below. Seems that hotplug is only trigerring ntpd events.
root@OpenWrt:~# ps | grep hotplug
2725 ntp 1120 S /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.n
11965 root 1120 R grep hotplug