hv_get_dhcp_info.sh 895 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # This example script retrieves the DHCP state of a given interface.
  3. # In the interest of keeping the KVP daemon code free of distro specific
  4. # information; the kvp daemon code invokes this external script to gather
  5. # DHCP setting for the specific interface.
  6. #
  7. # Input: Name of the interface
  8. #
  9. # Output: The script prints the string "Enabled" to stdout to indicate
  10. # that DHCP is enabled on the interface. If DHCP is not enabled,
  11. # the script prints the string "Disabled" to stdout.
  12. #
  13. # Each Distro is expected to implement this script in a distro specific
  14. # fashion. For instance on Distros that ship with Network Manager enabled,
  15. # this script can be based on the Network Manager APIs for retrieving DHCP
  16. # information.
  17. if_file="/etc/sysconfig/network-scripts/ifcfg-"$1
  18. dhcp=$(grep "dhcp" $if_file 2>/dev/null)
  19. if [ "$dhcp" != "" ];
  20. then
  21. echo "Enabled"
  22. else
  23. echo "Disabled"
  24. fi