18c2ecf20Sopenharmony_ci#!/bin/bash 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci# This example script retrieves the DHCP state of a given interface. 58c2ecf20Sopenharmony_ci# In the interest of keeping the KVP daemon code free of distro specific 68c2ecf20Sopenharmony_ci# information; the kvp daemon code invokes this external script to gather 78c2ecf20Sopenharmony_ci# DHCP setting for the specific interface. 88c2ecf20Sopenharmony_ci# 98c2ecf20Sopenharmony_ci# Input: Name of the interface 108c2ecf20Sopenharmony_ci# 118c2ecf20Sopenharmony_ci# Output: The script prints the string "Enabled" to stdout to indicate 128c2ecf20Sopenharmony_ci# that DHCP is enabled on the interface. If DHCP is not enabled, 138c2ecf20Sopenharmony_ci# the script prints the string "Disabled" to stdout. 148c2ecf20Sopenharmony_ci# 158c2ecf20Sopenharmony_ci# Each Distro is expected to implement this script in a distro specific 168c2ecf20Sopenharmony_ci# fashion. For instance, on Distros that ship with Network Manager enabled, 178c2ecf20Sopenharmony_ci# this script can be based on the Network Manager APIs for retrieving DHCP 188c2ecf20Sopenharmony_ci# information. 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciif_file="/etc/sysconfig/network-scripts/ifcfg-"$1 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cidhcp=$(grep "dhcp" $if_file 2>/dev/null) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciif [ "$dhcp" != "" ]; 258c2ecf20Sopenharmony_cithen 268c2ecf20Sopenharmony_ciecho "Enabled" 278c2ecf20Sopenharmony_cielse 288c2ecf20Sopenharmony_ciecho "Disabled" 298c2ecf20Sopenharmony_cifi 30