2009-11-06 08:34:19 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
2009-11-09 15:34:54 +05:30
|
|
|
#exec >/dev/null
|
2009-11-06 08:34:19 +05:30
|
|
|
exec 2>&1
|
|
|
|
exec </dev/null
|
|
|
|
|
|
|
|
pwd="$PWD"
|
|
|
|
|
|
|
|
if="${PWD##*/ifplugd_}"
|
|
|
|
|
2015-10-24 18:25:33 +05:30
|
|
|
echo "* Upping iface $if"
|
2019-04-21 18:00:19 +05:30
|
|
|
ip link set dev "$if" up || exec sleep 5
|
2015-10-24 18:25:33 +05:30
|
|
|
|
2009-11-07 22:24:44 +05:30
|
|
|
echo "* Starting ifplugd on $if [$$]"
|
2009-11-06 08:34:19 +05:30
|
|
|
exec \
|
|
|
|
env - PATH="$PATH" \
|
|
|
|
softlimit \
|
|
|
|
setuidgid root \
|
2019-01-18 18:44:07 +05:30
|
|
|
ifplugd -aqlMns -t3 -u8 -d8 -i "$if" -r "$pwd/ifplugd_handler"
|
2009-11-06 08:34:19 +05:30
|
|
|
|
2009-11-09 15:34:54 +05:30
|
|
|
# We use -t3 to wake ifplugd up less often.
|
|
|
|
# If after three tests (3*3=9 > 8) link state seen to be different,
|
|
|
|
# the handler will be called.
|
|
|
|
# IOW: short link losses will be ignored, longer ones
|
|
|
|
# will trigger DHCP reconfiguration and such (see handler code).
|
2009-11-07 22:24:44 +05:30
|
|
|
|
2018-03-30 23:32:33 +05:30
|
|
|
# -l makes ifplugd run either "up" or "down" script on startup.
|
|
|
|
# For example, if wired eth cable is unplugged, this stops dhcp service
|
|
|
|
# from pointlessly trying to get a lease.
|
|
|
|
# -q means that stopping monitoring does not stop dhcp/zcip/etc:
|
|
|
|
# presumably, admin decided to control them manually.
|
2019-01-18 18:44:07 +05:30
|
|
|
# -M prevents frequent respawning if device does not exist (yet?)
|
2018-03-30 23:32:33 +05:30
|
|
|
|
2018-03-30 14:44:46 +05:30
|
|
|
#-a Don't up interface automatically
|
|
|
|
#-p Don't run "up" script on startup
|
|
|
|
#-q Don't run "down" script on exit
|
|
|
|
#-l Always run script on startup
|
2009-11-06 08:34:19 +05:30
|
|
|
#-n Do not daemonize
|
|
|
|
#-s Do not log to syslog
|
2009-11-07 22:24:44 +05:30
|
|
|
#-t SECS Poll time in seconds
|
|
|
|
#-u SECS Delay before running script after link up
|
|
|
|
#-d SECS Delay after link down
|
2009-11-06 08:34:19 +05:30
|
|
|
#-i IFACE Interface
|
|
|
|
#-M Monitor creation/destruction of interface (otherwise it must exist)
|
2018-03-30 14:44:46 +05:30
|
|
|
#-r PROG Script to run
|
2009-11-06 08:34:19 +05:30
|
|
|
#-x ARG Extra argument for script
|
2018-03-30 14:44:46 +05:30
|
|
|
#-I Don't exit on nonzero exit code from script
|
|
|
|
#-f/-F Treat link detection error as link down/link up (otherwise exit on error)
|
2009-11-06 08:34:19 +05:30
|
|
|
#-m MODE API mode (mii, priv, ethtool, wlan, auto)
|
2018-03-30 14:44:46 +05:30
|
|
|
#-k Kill running daemon
|