hv_set_ifconfig.sh 1.8 KB

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