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