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