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