1271493Sdelphij#!/bin/sh 2271493Sdelphij 3271493Sdelphij# This script activates an interface based on the specified 4271493Sdelphij# configuration. The kvp daemon code invokes this external script 5271493Sdelphij# to configure the interface. 6271493Sdelphij# 7271493Sdelphij# The only argument to this script is the configuration file that is to 8271493Sdelphij# be used to configure the interface. 9271493Sdelphij# 10271493Sdelphij# Here is the format of the ip configuration file: 11271493Sdelphij# 12271493Sdelphij# HWADDR=macaddr 13271493Sdelphij# IF_NAME=interface name 14271493Sdelphij# DHCP=yes (This is optional; if yes, DHCP is configured) 15271493Sdelphij# 16271493Sdelphij# IPADDR=ipaddr1 17271493Sdelphij# IPADDR_1=ipaddr2 18271493Sdelphij# IPADDR_x=ipaddry (where y = x + 1) 19271493Sdelphij# 20271493Sdelphij# NETMASK=netmask1 21271493Sdelphij# NETMASK_x=netmasky (where y = x + 1) 22271493Sdelphij# 23271493Sdelphij# GATEWAY=ipaddr1 24271493Sdelphij# GATEWAY_x=ipaddry (where y = x + 1) 25271493Sdelphij# 26271493Sdelphij# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 27271493Sdelphij# 28271493Sdelphij# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be 29271493Sdelphij# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as 30271493Sdelphij# IPV6NETMASK. 31271493Sdelphij# 32271493Sdelphij# The host can specify multiple ipv4 and ipv6 addresses to be 33271493Sdelphij# configured for the interface. Furthermore, the configuration 34271493Sdelphij# needs to be persistent. A subsequent GET call on the interface 35271493Sdelphij# is expected to return the configuration that is set via the SET 36271493Sdelphij# call. 37271493Sdelphij# 38271493Sdelphij 39271493Sdelphij. $1 40271493Sdelphij 41271493Sdelphijsed -i".bak" '/ifconfig_hn0="SYNCDHCP"/d' /etc/rc.conf 42271493Sdelphijsed -i".bak" '/ifconfig_hn0="DHCP"/d' /etc/rc.conf 43271493Sdelphij 44271493Sdelphij# MAC Address 45271493Sdelphijifconfig $IF_NAME ether $HWADDR 46271493Sdelphij 47271493Sdelphij# IP and Subnet Mask 48271493Sdelphijifconfig $IF_NAME inet $IP_ADDR netmask $SUBNET 49271493Sdelphij 50271493Sdelphij# DNS 51271493Sdelphijsed -i".bak" '/nameserver/d' /etc/resolv.conf 52271493Sdelphijecho "nameserver" $DNS >> /etc/resolv.conf 53271493Sdelphij 54271493Sdelphij#Gateway 55271493Sdelphij# Need to implment if Gateway is not present 56271493Sdelphijroute flush 57271493Sdelphijroute add default $GATEWAY 58271493Sdelphij#route change default $GATEWAY 59271493Sdelphij 60271493Sdelphij#/etc/rc.d/netif restart 61271493Sdelphij#/etc/rc.d/routing restart 62271493Sdelphij 63271493Sdelphij 64271493Sdelphij# DHCP 65271493Sdelphijif [ $DHCP -eq 1 ] 66271493Sdelphijthen 67271493Sdelphij echo ifconfig_hn0=\"DHCP\" >> /etc/rc.conf 68271493Sdelphij echo Enabled 69271493Sdelphijelse 70271493Sdelphij echo Disabled DHCP >> /var/log/messages 71271493Sdelphij echo Disabled 72271493Sdelphijfi 73271493Sdelphijecho "Set IP-Injection Success" 74