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