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