1*e72055b7SXin LI#!/bin/sh 2*e72055b7SXin LI 3*e72055b7SXin LI# This script activates an interface based on the specified 4*e72055b7SXin LI# configuration. The kvp daemon code invokes this external script 5*e72055b7SXin LI# to configure the interface. 6*e72055b7SXin LI# 7*e72055b7SXin LI# The only argument to this script is the configuration file that is to 8*e72055b7SXin LI# be used to configure the interface. 9*e72055b7SXin LI# 10*e72055b7SXin LI# Here is the format of the ip configuration file: 11*e72055b7SXin LI# 12*e72055b7SXin LI# HWADDR=macaddr 13*e72055b7SXin LI# IF_NAME=interface name 14*e72055b7SXin LI# DHCP=yes (This is optional; if yes, DHCP is configured) 15*e72055b7SXin LI# 16*e72055b7SXin LI# IPADDR=ipaddr1 17*e72055b7SXin LI# IPADDR_1=ipaddr2 18*e72055b7SXin LI# IPADDR_x=ipaddry (where y = x + 1) 19*e72055b7SXin LI# 20*e72055b7SXin LI# NETMASK=netmask1 21*e72055b7SXin LI# NETMASK_x=netmasky (where y = x + 1) 22*e72055b7SXin LI# 23*e72055b7SXin LI# GATEWAY=ipaddr1 24*e72055b7SXin LI# GATEWAY_x=ipaddry (where y = x + 1) 25*e72055b7SXin LI# 26*e72055b7SXin LI# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 27*e72055b7SXin LI# 28*e72055b7SXin LI# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 29*e72055b7SXin LI# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 30*e72055b7SXin LI# IPV6NETMASK. 31*e72055b7SXin LI# 32*e72055b7SXin LI# The host can specify multiple ipv4 and ipv6 addresses to be 33*e72055b7SXin LI# configured for the interface. Furthermore, the configuration 34*e72055b7SXin LI# needs to be persistent. A subsequent GET call on the interface 35*e72055b7SXin LI# is expected to return the configuration that is set via the SET 36*e72055b7SXin LI# call. 37*e72055b7SXin LI# 38*e72055b7SXin LI 39*e72055b7SXin LI. $1 40*e72055b7SXin LI 41*e72055b7SXin LIsed -i".bak" '/ifconfig_hn0="SYNCDHCP"/d' /etc/rc.conf 42*e72055b7SXin LIsed -i".bak" '/ifconfig_hn0="DHCP"/d' /etc/rc.conf 43*e72055b7SXin LI 44*e72055b7SXin LI# MAC Address 45*e72055b7SXin LIifconfig $IF_NAME ether $HWADDR 46*e72055b7SXin LI 47*e72055b7SXin LI# IP and Subnet Mask 48*e72055b7SXin LIifconfig $IF_NAME inet $IP_ADDR netmask $SUBNET 49*e72055b7SXin LI 50*e72055b7SXin LI# DNS 51*e72055b7SXin LIsed -i".bak" '/nameserver/d' /etc/resolv.conf 52*e72055b7SXin LIecho "nameserver" $DNS >> /etc/resolv.conf 53*e72055b7SXin LI 54*e72055b7SXin LI#Gateway 55*e72055b7SXin LI# Need to implment if Gateway is not present 56*e72055b7SXin LIroute flush 57*e72055b7SXin LIroute add default $GATEWAY 58*e72055b7SXin LI#route change default $GATEWAY 59*e72055b7SXin LI 60*e72055b7SXin LI#/etc/rc.d/netif restart 61*e72055b7SXin LI#/etc/rc.d/routing restart 62*e72055b7SXin LI 63*e72055b7SXin LI 64*e72055b7SXin LI# DHCP 65*e72055b7SXin LIif [ $DHCP -eq 1 ] 66*e72055b7SXin LIthen 67*e72055b7SXin LI echo ifconfig_hn0=\"DHCP\" >> /etc/rc.conf 68*e72055b7SXin LI echo Enabled 69*e72055b7SXin LIelse 70*e72055b7SXin LI echo Disabled DHCP >> /var/log/messages 71*e72055b7SXin LI echo Disabled 72*e72055b7SXin LIfi 73*e72055b7SXin LIecho "Set IP-Injection Success" 74