dhcpcd 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # Begin services/dhcpcd
  3. # Origianlly dased upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up}
  4. # Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
  5. # Adapted for dhcpcd by DJ Lucas <dj@linuxfromscratch.org>
  6. # Update for LFS 7.0 by Bruce Dubbs <bdubbs@linuxfromscratch,org>
  7. # Call with: IFCONFIG=<filename> /lib/services/dhcpcd <IFACE> <up | down>
  8. #$LastChangedBy: bdubbs $
  9. #$Date: 2012-04-09 14:48:51 -0500 (Mon, 09 Apr 2012) $
  10. . /lib/lsb/init-functions
  11. . $IFCONFIG
  12. pidfile="/var/run/dhcpcd-$1.pid"
  13. case "$2" in
  14. up)
  15. # Cosmetic output not needed for multiple services
  16. if ! $(echo ${SERVICE} | grep -q " "); then
  17. log_info_msg2 "\n" # Terminate the previous message
  18. fi
  19. log_info_msg "Starting dhcpcd on the $1 interface..."
  20. # Test to see if there is a stale pid file
  21. if [ -f "$pidfile" ]; then
  22. ps `cat "$pidfile"` | grep dhcpcd > /dev/null
  23. if [ $? != 0 ]; then
  24. rm -f /var/run/dhcpcd-$1.pid > /dev/null
  25. else
  26. log_warning_msg "dhcpcd is already running!"
  27. exit 2
  28. fi
  29. fi
  30. /sbin/dhcpcd $1 $DHCP_START
  31. evaluate_retval
  32. ;;
  33. down)
  34. log_info_msg "Stopping dhcpcd on the $1 interface..."
  35. if [ -z "$DHCP_STOP" ]; then
  36. killproc -p "${pidfile}" /sbin/dhcpcd
  37. else
  38. /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null
  39. if [ "$?" -eq 1 ]; then
  40. log_warning_msg "dhcpcd not running!"
  41. exit 2
  42. fi
  43. fi
  44. evaluate_retval
  45. ;;
  46. *)
  47. echo "Usage: $0 [interface] {up|down}"
  48. exit 1
  49. ;;
  50. esac
  51. # End services/dhcpcd