Hotplug extras

  • This instruction extends the functionality of Hotplug.
  • Follow the automated section for quick setup.
  • Run scripts at startup when the network is online.
  • Use Hotplug to detect connectivity change 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
if [ "${INTERFACE}" = "loopback" ]
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
# Example Hotplug script
cat << "EOF" > /etc/hotplug.d/online/00-logger
logger -t hotplug $(env)
EOF
 
# Trigger Hotplug
service network restart
 
# Check Hotplug log
logread -e hotplug
wget -U "" -O hotplug-extras.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/hotplug_extras?codeblock=0"
. ./hotplug-extras.sh
  • Last modified: 2023/10/14 05:44
  • by vgaetera