#!/bin/bash1# SPDX-License-Identifier: GPL-2.023# This example script activates an interface based on the specified4# configuration.5#6# In the interest of keeping the KVP daemon code free of distro specific7# information; the kvp daemon code invokes this external script to configure8# the interface.9#10# The only argument to this script is the configuration file that is to11# be used to configure the interface.12#13# Each Distro is expected to implement this script in a distro specific14# fashion. For instance, on Distros that ship with Network Manager enabled,15# this script can be based on the Network Manager APIs for configuring the16# interface.17#18# This example script is based on a RHEL environment.19#20# Here is the ifcfg format of the ip configuration file:21#22# HWADDR=macaddr23# DEVICE=interface name24# BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured25# or "none" if no boot-time protocol should be used)26#27# IPADDR0=ipaddr128# IPADDR1=ipaddr229# IPADDRx=ipaddry (where y = x + 1)30#31# NETMASK0=netmask132# NETMASKx=netmasky (where y = x + 1)33#34# GATEWAY=ipaddr135# GATEWAYx=ipaddry (where y = x + 1)36#37# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)38#39# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be40# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as41# IPV6NETMASK.42#43# Here is the keyfile format of the ip configuration file:44#45# [ethernet]46# mac-address=macaddr47# [connection]48# interface-name=interface name49#50# [ipv4]51# method=<protocol> (where <protocol> is "auto" if DHCP is configured52# or "manual" if no boot-time protocol should be used)53#54# address1=ipaddr1/plen55# address2=ipaddr2/plen56#57# gateway=gateway1;gateway258#59# dns=dns1;60#61# [ipv6]62# address1=ipaddr1/plen63# address2=ipaddr2/plen64#65# gateway=gateway1;gateway266#67# dns=dns1;dns268#69# The host can specify multiple ipv4 and ipv6 addresses to be70# configured for the interface. Furthermore, the configuration71# needs to be persistent. A subsequent GET call on the interface72# is expected to return the configuration that is set via the SET73# call.74#7576echo "IPV6INIT=yes" >> $177echo "NM_CONTROLLED=no" >> $178echo "PEERDNS=yes" >> $179echo "ONBOOT=yes" >> $18081cp $1 /etc/sysconfig/network-scripts/8283umask 017784interface=$(echo $2 | awk -F - '{ print $2 }')85filename="${2##*/}"8687sed '/\[connection\]/a autoconnect=true' $2 > /etc/NetworkManager/system-connections/${filename}888990/sbin/ifdown $interface 2>/dev/null91/sbin/ifup $interface 2>/dev/null929394