Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # This example script activates an interface based on the specified
0005 # configuration.
0006 #
0007 # In the interest of keeping the KVP daemon code free of distro specific
0008 # information; the kvp daemon code invokes this external script to configure
0009 # the interface.
0010 #
0011 # The only argument to this script is the configuration file that is to
0012 # be used to configure the interface.
0013 #
0014 # Each Distro is expected to implement this script in a distro specific
0015 # fashion. For instance, on Distros that ship with Network Manager enabled,
0016 # this script can be based on the Network Manager APIs for configuring the
0017 # interface.
0018 #
0019 # This example script is based on a RHEL environment.
0020 #
0021 # Here is the format of the ip configuration file:
0022 #
0023 # HWADDR=macaddr
0024 # DEVICE=interface name
0025 # BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
0026 #                       or "none" if no boot-time protocol should be used)
0027 #
0028 # IPADDR0=ipaddr1
0029 # IPADDR1=ipaddr2
0030 # IPADDRx=ipaddry (where y = x + 1)
0031 #
0032 # NETMASK0=netmask1
0033 # NETMASKx=netmasky (where y = x + 1)
0034 #
0035 # GATEWAY=ipaddr1
0036 # GATEWAYx=ipaddry (where y = x + 1)
0037 #
0038 # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
0039 #
0040 # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be
0041 # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as
0042 # IPV6NETMASK.
0043 #
0044 # The host can specify multiple ipv4 and ipv6 addresses to be
0045 # configured for the interface. Furthermore, the configuration
0046 # needs to be persistent. A subsequent GET call on the interface
0047 # is expected to return the configuration that is set via the SET
0048 # call.
0049 #
0050 
0051 
0052 
0053 echo "IPV6INIT=yes" >> $1
0054 echo "NM_CONTROLLED=no" >> $1
0055 echo "PEERDNS=yes" >> $1
0056 echo "ONBOOT=yes" >> $1
0057 
0058 
0059 cp $1 /etc/sysconfig/network-scripts/
0060 
0061 
0062 interface=$(echo $1 | awk -F - '{ print $2 }')
0063 
0064 /sbin/ifdown $interface 2>/dev/null
0065 /sbin/ifup $interface 2>/dev/null