Blame SOURCES/hv_get_dhcp_info.sh

b19ffd
#!/bin/bash
b19ffd
# SPDX-License-Identifier: GPL-2.0
b19ffd
b19ffd
# This example script retrieves the DHCP state of a given interface.
b19ffd
# In the interest of keeping the KVP daemon code free of distro specific
b19ffd
# information; the kvp daemon code invokes this external script to gather
b19ffd
# DHCP setting for the specific interface.
b19ffd
#
b19ffd
# Input: Name of the interface
b19ffd
#
b19ffd
# Output: The script prints the string "Enabled" to stdout to indicate
b19ffd
#	that DHCP is enabled on the interface. If DHCP is not enabled,
b19ffd
#	the script prints the string "Disabled" to stdout.
b19ffd
#
b19ffd
# Each Distro is expected to implement this script in a distro specific
b19ffd
# fashion. For instance on Distros that ship with Network Manager enabled,
b19ffd
# this script can be based on the Network Manager APIs for retrieving DHCP
b19ffd
# information.
b19ffd
b19ffd
if_file="/etc/sysconfig/network-scripts/ifcfg-"$1
b19ffd
b19ffd
dhcp=$(grep "dhcp" $if_file 2>/dev/null)
b19ffd
b19ffd
if [ "$dhcp" != "" ];
b19ffd
then
b19ffd
echo "Enabled"
b19ffd
else
b19ffd
echo "Disabled"
b19ffd
fi