18c2ecf20Sopenharmony_ci#!/bin/bash 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci# This example script activates an interface based on the specified 58c2ecf20Sopenharmony_ci# configuration. 68c2ecf20Sopenharmony_ci# 78c2ecf20Sopenharmony_ci# In the interest of keeping the KVP daemon code free of distro specific 88c2ecf20Sopenharmony_ci# information; the kvp daemon code invokes this external script to configure 98c2ecf20Sopenharmony_ci# the interface. 108c2ecf20Sopenharmony_ci# 118c2ecf20Sopenharmony_ci# The only argument to this script is the configuration file that is to 128c2ecf20Sopenharmony_ci# be used to configure the interface. 138c2ecf20Sopenharmony_ci# 148c2ecf20Sopenharmony_ci# Each Distro is expected to implement this script in a distro specific 158c2ecf20Sopenharmony_ci# fashion. For instance, on Distros that ship with Network Manager enabled, 168c2ecf20Sopenharmony_ci# this script can be based on the Network Manager APIs for configuring the 178c2ecf20Sopenharmony_ci# interface. 188c2ecf20Sopenharmony_ci# 198c2ecf20Sopenharmony_ci# This example script is based on a RHEL environment. 208c2ecf20Sopenharmony_ci# 218c2ecf20Sopenharmony_ci# Here is the format of the ip configuration file: 228c2ecf20Sopenharmony_ci# 238c2ecf20Sopenharmony_ci# HWADDR=macaddr 248c2ecf20Sopenharmony_ci# DEVICE=interface name 258c2ecf20Sopenharmony_ci# BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured 268c2ecf20Sopenharmony_ci# or "none" if no boot-time protocol should be used) 278c2ecf20Sopenharmony_ci# 288c2ecf20Sopenharmony_ci# IPADDR0=ipaddr1 298c2ecf20Sopenharmony_ci# IPADDR1=ipaddr2 308c2ecf20Sopenharmony_ci# IPADDRx=ipaddry (where y = x + 1) 318c2ecf20Sopenharmony_ci# 328c2ecf20Sopenharmony_ci# NETMASK0=netmask1 338c2ecf20Sopenharmony_ci# NETMASKx=netmasky (where y = x + 1) 348c2ecf20Sopenharmony_ci# 358c2ecf20Sopenharmony_ci# GATEWAY=ipaddr1 368c2ecf20Sopenharmony_ci# GATEWAYx=ipaddry (where y = x + 1) 378c2ecf20Sopenharmony_ci# 388c2ecf20Sopenharmony_ci# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 398c2ecf20Sopenharmony_ci# 408c2ecf20Sopenharmony_ci# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 418c2ecf20Sopenharmony_ci# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 428c2ecf20Sopenharmony_ci# IPV6NETMASK. 438c2ecf20Sopenharmony_ci# 448c2ecf20Sopenharmony_ci# The host can specify multiple ipv4 and ipv6 addresses to be 458c2ecf20Sopenharmony_ci# configured for the interface. Furthermore, the configuration 468c2ecf20Sopenharmony_ci# needs to be persistent. A subsequent GET call on the interface 478c2ecf20Sopenharmony_ci# is expected to return the configuration that is set via the SET 488c2ecf20Sopenharmony_ci# call. 498c2ecf20Sopenharmony_ci# 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciecho "IPV6INIT=yes" >> $1 548c2ecf20Sopenharmony_ciecho "NM_CONTROLLED=no" >> $1 558c2ecf20Sopenharmony_ciecho "PEERDNS=yes" >> $1 568c2ecf20Sopenharmony_ciecho "ONBOOT=yes" >> $1 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cicp $1 /etc/sysconfig/network-scripts/ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciinterface=$(echo $1 | awk -F - '{ print $2 }') 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/sbin/ifdown $interface 2>/dev/null 658c2ecf20Sopenharmony_ci/sbin/ifup $interface 2>/dev/null 66