Blame SOURCES/hv_set_ifconfig.sh

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