Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # This example script retrieves the DHCP state of a given interface.
0005 # In the interest of keeping the KVP daemon code free of distro specific
0006 # information; the kvp daemon code invokes this external script to gather
0007 # DHCP setting for the specific interface.
0008 #
0009 # Input: Name of the interface
0010 #
0011 # Output: The script prints the string "Enabled" to stdout to indicate
0012 #       that DHCP is enabled on the interface. If DHCP is not enabled,
0013 #       the script prints the string "Disabled" to stdout.
0014 #
0015 # Each Distro is expected to implement this script in a distro specific
0016 # fashion. For instance, on Distros that ship with Network Manager enabled,
0017 # this script can be based on the Network Manager APIs for retrieving DHCP
0018 # information.
0019 
0020 if_file="/etc/sysconfig/network-scripts/ifcfg-"$1
0021 
0022 dhcp=$(grep "dhcp" $if_file 2>/dev/null)
0023 
0024 if [ "$dhcp" != "" ];
0025 then
0026 echo "Enabled"
0027 else
0028 echo "Disabled"
0029 fi