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