Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 002bdc3 | 2009-11-09 11:04:54 +0100 | [diff] [blame] | 3 | #exec >/dev/null |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 4 | exec 2>&1 |
| 5 | exec </dev/null |
| 6 | |
| 7 | pwd="$PWD" |
| 8 | |
| 9 | if="${PWD##*/ifplugd_}" |
| 10 | |
Denys Vlasenko | bf40f56 | 2009-11-07 17:54:44 +0100 | [diff] [blame] | 11 | echo "* Starting ifplugd on $if [$$]" |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 12 | exec \ |
| 13 | env - PATH="$PATH" \ |
| 14 | softlimit \ |
| 15 | setuidgid root \ |
Denys Vlasenko | 002bdc3 | 2009-11-09 11:04:54 +0100 | [diff] [blame] | 16 | ifplugd -apqns -t3 -u8 -d8 -i "$if" -r "$pwd/ifplugd_handler" |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 17 | |
Denys Vlasenko | 002bdc3 | 2009-11-09 11:04:54 +0100 | [diff] [blame] | 18 | # We use -t3 to wake ifplugd up less often. |
| 19 | # If after three tests (3*3=9 > 8) link state seen to be different, |
| 20 | # the handler will be called. |
| 21 | # IOW: short link losses will be ignored, longer ones |
| 22 | # will trigger DHCP reconfiguration and such (see handler code). |
Denys Vlasenko | bf40f56 | 2009-11-07 17:54:44 +0100 | [diff] [blame] | 23 | |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 24 | #-a Do not up interface automatically |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 25 | #-p Dont run script on daemon startup |
| 26 | #-q Dont run script on daemon quit |
Denys Vlasenko | bf40f56 | 2009-11-07 17:54:44 +0100 | [diff] [blame] | 27 | #-n Do not daemonize |
| 28 | #-s Do not log to syslog |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 29 | #-t SECS Poll time in seconds |
| 30 | #-u SECS Delay before running script after link up |
| 31 | #-d SECS Delay after link down |
Denys Vlasenko | bf40f56 | 2009-11-07 17:54:44 +0100 | [diff] [blame] | 32 | #-i IFACE Interface |
| 33 | #-r PROG Script to run |
| 34 | #-f/-F Treat link detection error as link down/link up (otherwise exit on error) |
| 35 | #-M Monitor creation/destruction of interface (otherwise it must exist) |
| 36 | #-x ARG Extra argument for script |
| 37 | #-I Dont exit on nonzero exit code from script |
| 38 | #-l Run script on startup even if no cable is detected |
Denys Vlasenko | 6cf7f01 | 2009-11-06 04:04:19 +0100 | [diff] [blame] | 39 | #-m MODE API mode (mii, priv, ethtool, wlan, auto) |