K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0 |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 3 | |
| 4 | # This example script activates an interface based on the specified |
| 5 | # configuration. |
| 6 | # |
| 7 | # In the interest of keeping the KVP daemon code free of distro specific |
| 8 | # information; the kvp daemon code invokes this external script to configure |
| 9 | # the interface. |
| 10 | # |
| 11 | # The only argument to this script is the configuration file that is to |
| 12 | # be used to configure the interface. |
| 13 | # |
| 14 | # Each Distro is expected to implement this script in a distro specific |
Adrian Vladu | 2d35c66 | 2019-05-06 16:51:24 +0000 | [diff] [blame] | 15 | # fashion. For instance, on Distros that ship with Network Manager enabled, |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 16 | # this script can be based on the Network Manager APIs for configuring the |
| 17 | # interface. |
| 18 | # |
| 19 | # This example script is based on a RHEL environment. |
| 20 | # |
| 21 | # Here is the format of the ip configuration file: |
| 22 | # |
| 23 | # HWADDR=macaddr |
Tomas Hozza | 0783d72 | 2013-01-13 22:27:40 +0100 | [diff] [blame] | 24 | # DEVICE=interface name |
| 25 | # BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured |
| 26 | # or "none" if no boot-time protocol should be used) |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 27 | # |
Tomas Hozza | 0783d72 | 2013-01-13 22:27:40 +0100 | [diff] [blame] | 28 | # IPADDR0=ipaddr1 |
| 29 | # IPADDR1=ipaddr2 |
| 30 | # IPADDRx=ipaddry (where y = x + 1) |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 31 | # |
Tomas Hozza | 0783d72 | 2013-01-13 22:27:40 +0100 | [diff] [blame] | 32 | # NETMASK0=netmask1 |
| 33 | # NETMASKx=netmasky (where y = x + 1) |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 34 | # |
| 35 | # GATEWAY=ipaddr1 |
Tomas Hozza | 0783d72 | 2013-01-13 22:27:40 +0100 | [diff] [blame] | 36 | # GATEWAYx=ipaddry (where y = x + 1) |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 37 | # |
| 38 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) |
| 39 | # |
| 40 | # IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be |
| 41 | # tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as |
| 42 | # IPV6NETMASK. |
| 43 | # |
| 44 | # The host can specify multiple ipv4 and ipv6 addresses to be |
| 45 | # configured for the interface. Furthermore, the configuration |
| 46 | # needs to be persistent. A subsequent GET call on the interface |
| 47 | # is expected to return the configuration that is set via the SET |
| 48 | # call. |
| 49 | # |
| 50 | |
| 51 | |
| 52 | |
| 53 | echo "IPV6INIT=yes" >> $1 |
| 54 | echo "NM_CONTROLLED=no" >> $1 |
| 55 | echo "PEERDNS=yes" >> $1 |
| 56 | echo "ONBOOT=yes" >> $1 |
| 57 | |
K. Y. Srinivasan | 1fbdba4 | 2012-09-05 13:50:12 -0700 | [diff] [blame] | 58 | |
| 59 | cp $1 /etc/sysconfig/network-scripts/ |
| 60 | |
| 61 | |
| 62 | interface=$(echo $1 | awk -F - '{ print $2 }') |
| 63 | |
| 64 | /sbin/ifdown $interface 2>/dev/null |
Jason Wang | 00246d0 | 2013-01-05 13:03:06 +0800 | [diff] [blame] | 65 | /sbin/ifup $interface 2>/dev/null |