Hotplug extras

  • This instruction extends Hotplug functionality.
  • Follow the automated section for quick setup.
  • Run scripts at startup when the network is online.
  • Rely on network functions to identify WAN interface.
  • Use Hotplug to detect WAN connectivity and trigger network dependent scripts.
  • Process subsystem-specific scripts with hotplug-call.
  • Delay script invocation with sleep to work around tunneled connections.
  • Write and read non-interactive logs with Syslog for troubleshooting.
# Configure hotplug
mkdir -p /etc/hotplug.d/iface
cat << "EOF" > /etc/hotplug.d/iface/90-online
. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_find_wan6 NET_IF6
if [ "${INTERFACE}" != "${NET_IF}" ] \
&& [ "${INTERFACE}" != "${NET_IF6}" ]
then exit 0
fi
if [ "${ACTION}" != "ifup" ] \
&& [ "${ACTION}" != "ifupdate" ]
then exit 0
fi
if [ "${ACTION}" = "ifupdate" ] \
&& [ -z "${IFUPDATE_ADDRESSES}" ] \
&& [ -z "${IFUPDATE_DATA}" ]
then exit 0
fi
hotplug-call online
EOF
cat << "EOF" >> /etc/sysupgrade.conf
/etc/hotplug.d/iface/90-online
EOF
mkdir -p /etc/hotplug.d/online
cat << "EOF" > /etc/hotplug.d/online/10-sleep
sleep 10
EOF
cat << "EOF" >> /etc/sysupgrade.conf
/etc/hotplug.d/online/10-sleep
EOF
# Example script
cat << "EOF" > /etc/hotplug.d/online/30-example
logger -t hotplug online
EOF
reboot
alias uclient-fetch="uclient-fetch --no-check-certificate"
uclient-fetch -O hotplug-extras.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/hotplug_extras?codeblock=0"
. ./hotplug-extras.sh
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/14 21:55
  • by vgaetera