Requirement: Get the current WAN/WAN_6/LAN interface IPv6 address when the PPPoE dial-up is completed or the interface IP address changes, and record it in the log file. Now the function of the script to obtain the interface IPv6 address is normal, but there are some problems with the trigger condition of the OpenWrt Hotplug script.
/etc/hotplug.d/iface
#!/bin/sh
if [$ACTION=ifup -a $INTERFACE=wan ]; then
sh xxx.sh
fi
The above script will be executed at an indefinite interval of time without executing ifup or without PPPoE.
/etc/hotplug.d/iface
#!/bin/sh
case "$ACTION" in
ifup)
sh xxx.sh
;;
esac
According to this writing method, then the script triggering feels like normal, I don't know what the problem is.
I didn't understand it too much. My doubt is that there are fewer trigger conditions in the script I wrote, and the restriction should be stricter, but this restriction is invalid. The reference method you gave here is more trigger conditions. The trigger condition I want is only to execute the script after pppoe dialing is completed
Probably not your issue, but I would use double quotes around the variable names and more importantly spaces around the equality sign so "$ACTION" = "ifup" instead of $ACTION=ifup, like so:
if [ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ]; then
sh xxx.sh
fi
Thank you, I will first test whether the script is normal, this script is an example from other people. What I don't understand is that if the script is not normal, it should not meet the conditions. I read that in the official documentation, hotplug iface has IFUPDATE_ADDRESSES variable
if [ "$IFUPDATE_ADDRESSES" = "1" ] && [ "$INTERFACE" = "wan_6" ]; then
sh xxx.sh
fi
The above script means that the script will be triggered when the IP address of the wan_6 interface changes, and the variable INTERFACE can match the WAN_6 virtual dynamic interface (DHCPv6 client) that is automatically created after PPPoE dialing is completed?
Thank you, I will first test whether the script is normal, this script is an example from other people. What I don't understand is that if the script is not normal, it should not meet the conditions.
Now the judgment condition of the script has been changed to the above. After the modification is completed, there is still an abnormal trigger. Observe for a while and then see if there are any problems, thank you!
I feel that this system is not implemented using standard script syntax. In addition, "${IFUPDATE_PREFIXES}" = "1" only judges this condition. It is clear that the prefix has been modified after PPPoE dialing, but this condition has not been triggered. I don’t know why.