S80dhcp-relay 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. #
  3. # $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $
  4. #
  5. # What servers should the DHCP relay forward requests to?
  6. # e.g: SERVERS="192.168.0.1"
  7. SERVERS=""
  8. # On what interfaces should the DHCP relay (dhrelay) serve DHCP requests?
  9. INTERFACES=""
  10. # Additional options that are passed to the DHCP relay daemon?
  11. OPTIONS=""
  12. # Read configuration variable file if it is present
  13. CFG_FILE="/etc/default/dhcrelay"
  14. [ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
  15. # Sanity checks
  16. test -f /usr/sbin/dhcrelay || exit 0
  17. test -n "$INTERFACES" || exit 0
  18. test -n "$SERVERS" || exit 0
  19. # Build command line for interfaces (will be passed to dhrelay below.)
  20. IFCMD=""
  21. for I in $INTERFACES; do
  22. IFCMD=${IFCMD}"-i "${I}" "
  23. done
  24. DHCRELAYPID=/var/run/dhcrelay.pid
  25. case "$1" in
  26. start)
  27. printf "Starting DHCP relay: "
  28. start-stop-daemon -S -q -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
  29. [ $? = 0 ] && echo "OK" || echo "FAIL"
  30. ;;
  31. stop)
  32. printf "Stopping DHCP relay: "
  33. start-stop-daemon -K -q -x /usr/sbin/dhcrelay
  34. [ $? = 0 ] && echo "OK" || echo "FAIL"
  35. ;;
  36. restart | force-reload)
  37. $0 stop
  38. $0 start
  39. ;;
  40. *)
  41. echo "Usage: $0 {start|stop|restart|force-reload}"
  42. exit 1
  43. esac
  44. exit 0