Blame SOURCES/hv_set_ifconfig.sh

146f51
#!/bin/bash
146f51
# SPDX-License-Identifier: GPL-2.0
146f51
146f51
# This example script activates an interface based on the specified
146f51
# configuration.
146f51
#
146f51
# In the interest of keeping the KVP daemon code free of distro specific
146f51
# information; the kvp daemon code invokes this external script to configure
146f51
# the interface.
146f51
#
146f51
# The only argument to this script is the configuration file that is to
146f51
# be used to configure the interface.
146f51
#
146f51
# Each Distro is expected to implement this script in a distro specific
146f51
# fashion. For instance on Distros that ship with Network Manager enabled,
146f51
# this script can be based on the Network Manager APIs for configuring the
146f51
# interface.
146f51
#
146f51
# This example script is based on a RHEL environment.
146f51
#
146f51
# Here is the format of the ip configuration file:
146f51
#
146f51
# HWADDR=macaddr
146f51
# DEVICE=interface name
146f51
# BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
146f51
#                       or "none" if no boot-time protocol should be used)
146f51
#
146f51
# IPADDR0=ipaddr1
146f51
# IPADDR1=ipaddr2
146f51
# IPADDRx=ipaddry (where y = x + 1)
146f51
#
146f51
# NETMASK0=netmask1
146f51
# NETMASKx=netmasky (where y = x + 1)
146f51
#
146f51
# GATEWAY=ipaddr1
146f51
# GATEWAYx=ipaddry (where y = x + 1)
146f51
#
146f51
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
146f51
#
146f51
# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be
146f51
# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as
146f51
# IPV6NETMASK.
146f51
#
146f51
# The host can specify multiple ipv4 and ipv6 addresses to be
146f51
# configured for the interface. Furthermore, the configuration
146f51
# needs to be persistent. A subsequent GET call on the interface
146f51
# is expected to return the configuration that is set via the SET
146f51
# call.
146f51
#
146f51
146f51
146f51
146f51
echo "IPV6INIT=yes" >> $1
146f51
echo "NM_CONTROLLED=no" >> $1
146f51
echo "PEERDNS=yes" >> $1
146f51
echo "ONBOOT=yes" >> $1
146f51
146f51
146f51
cp $1 /etc/sysconfig/network-scripts/
146f51
146f51
146f51
interface=$(echo $1 | awk -F - '{ print $2 }')
146f51
146f51
/sbin/ifdown $interface 2>/dev/null
146f51
/sbin/ifup $interface 2>/dev/null