3
0

run 1.6 KB

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