[184] | 1 | #!/bin/bash |
---|
| 2 | # Program: |
---|
| 3 | # Path DRBL evironment to support Xen/KVM |
---|
| 4 | # Author: |
---|
| 5 | # Jazz, Rock {jazz, rock}@nchc.org.tw |
---|
| 6 | # Version: |
---|
| 7 | # 1.0 |
---|
| 8 | # History: |
---|
| 9 | # 2010/07/20 Rock First release (1.0) |
---|
| 10 | |
---|
| 11 | # [Source] |
---|
| 12 | source /opt/drbl-virt/conf/drbl-virt.conf |
---|
| 13 | source $Work_Path/functions_drbl_virt |
---|
| 14 | |
---|
| 15 | # [Main] |
---|
| 16 | |
---|
| 17 | # = 0. Variables setup = |
---|
| 18 | # == Get DRBL eth == |
---|
| 19 | eths="" |
---|
| 20 | declare -i eth_nu="" |
---|
| 21 | get_DRBL_eth |
---|
| 22 | |
---|
| 23 | if [ $eth_nu -gt "1" ]; then |
---|
| 24 | echo "" |
---|
| 25 | echo "DRBL environment has muiltpule netwrok card(NIC)." |
---|
| 26 | fi |
---|
| 27 | |
---|
| 28 | for eth in $eths |
---|
| 29 | do |
---|
| 30 | |
---|
| 31 | # == Get Host IP range/number == |
---|
| 32 | Host_first_IP="" |
---|
| 33 | Host_last_IP="" |
---|
| 34 | # get eth network |
---|
| 35 | eth_address=$(/opt/drbl/bin/drbl-get-ipadd $eth) |
---|
| 36 | eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $eth) |
---|
| 37 | eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask) |
---|
| 38 | get_Host_IP_range |
---|
| 39 | |
---|
| 40 | # == Get VM number, IP range & prefix name == |
---|
| 41 | declare -i VM_IP_range="" |
---|
| 42 | declare -i Host_last_IP_4="" |
---|
| 43 | declare -i VM_Host_totoal_nu="" |
---|
| 44 | VM_first_IP="" |
---|
| 45 | VM_last_IP="" |
---|
| 46 | VM_prefix_name="" |
---|
| 47 | get_VM_IP_range_and_prefix_name |
---|
| 48 | create_VM_IP_table |
---|
| 49 | |
---|
| 50 | # == Generate MAC address == |
---|
| 51 | # MAC address [00:16:3e:xx:xx:xx] is for Xen use |
---|
| 52 | generate_Xen_MAC_address |
---|
| 53 | |
---|
| 54 | # == Add VM IP to dhcpd.conf == |
---|
| 55 | VM_IPs=$(cat /opt/drbl-virt/etc/IP_VM_$eth | awk '{print $1}') |
---|
| 56 | VM_hosts=$(cat /opt/drbl-virt/etc/IP_VM_$eth | awk '{print $2}') |
---|
| 57 | VM_MACs=$(cat /opt/drbl-virt/etc/macadr-VM-$eth.txt) |
---|
| 58 | add_VM_dhcpd_conf |
---|
| 59 | |
---|
| 60 | # == Add VM IP to exports == |
---|
| 61 | #add_VM_nfs_exportd |
---|
| 62 | |
---|
| 63 | # == Add VM IP to ypserv.securenets == |
---|
| 64 | #add_VM_ypserv_securenets |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | done |
---|
| 68 | |
---|
| 69 | # = 1. Copy VM fs = |
---|
| 70 | # Kernel & initrd -> /home/domains |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | # = 2. Add NFS config = |
---|
| 74 | |
---|
| 75 | # = 3. Add DHCP config = |
---|
| 76 | |
---|
| 77 | # = 4. Add hosts and cp it to all drbl client = |
---|
| 78 | |
---|
| 79 | # = 5. generate guest config file = |
---|