Blame SOURCES/hv_set_ifconfig.sh

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