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 | # = 1. 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 | # backup IP_HOST_TABLE |
---|
29 | if [ -e /etc/drbl/IP_HOST_TABLE.drbl-virt_bak ]; then |
---|
30 | cp /etc/drbl/IP_HOST_TABLE /etc/drbl/IP_HOST_TABLE.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak |
---|
31 | cp -f /etc/drbl/IP_HOST_TABLE.drbl-virt_bak /etc/drbl/IP_HOST_TABLE |
---|
32 | else |
---|
33 | cp /etc/drbl/IP_HOST_TABLE /etc/drbl/IP_HOST_TABLE.drbl-virt_bak |
---|
34 | fi |
---|
35 | |
---|
36 | for eth in $eths |
---|
37 | do |
---|
38 | |
---|
39 | # == Get Host IP range/number == |
---|
40 | Host_first_IP="" |
---|
41 | Host_last_IP="" |
---|
42 | # get eth network |
---|
43 | eth_address=$(/opt/drbl/bin/drbl-get-ipadd $eth) |
---|
44 | eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $eth) |
---|
45 | eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask) |
---|
46 | get_Host_IP_range |
---|
47 | |
---|
48 | # == Get VM number, IP range & prefix name == |
---|
49 | declare -i VM_IP_range="" |
---|
50 | declare -i Host_last_IP_4="" |
---|
51 | declare -i VM_Host_totoal_nu="" |
---|
52 | VM_first_IP="" |
---|
53 | VM_last_IP="" |
---|
54 | VM_prefix_name="" |
---|
55 | |
---|
56 | get_VM_IP_range_and_prefix_name |
---|
57 | create_VM_IP_table |
---|
58 | |
---|
59 | # == Generate MAC address == |
---|
60 | # MAC address [00:16:3e:xx:xx:xx] is for Xen use |
---|
61 | generate_Xen_MAC_address |
---|
62 | |
---|
63 | # == Add VM IP to /etc/drbl/IP_HOST_TABLE == |
---|
64 | VM_IPs=$(cat /opt/drbl-virt/etc/IP_VM_$eth | awk '{print $1}') |
---|
65 | VM_IPs_nu=$(cat /opt/drbl-virt/etc/IP_VM_eth1 | awk '{print $1}' | wc -w) |
---|
66 | VM_hosts=$(cat /opt/drbl-virt/etc/IP_VM_$eth | awk '{print $2}') |
---|
67 | VM_MACs=$(cat /opt/drbl-virt/etc/macadr-VM-$eth.txt) |
---|
68 | |
---|
69 | # == Add Mac address to macadr-ethX.txt == |
---|
70 | if [ -e /etc/drbl/macadr-$eth.txt ]; then |
---|
71 | delete_duplicating_MAC |
---|
72 | fi |
---|
73 | cat /opt/drbl-virt/etc/macadr-VM-$eth.txt >> /etc/drbl/macadr-$eth.txt |
---|
74 | done |
---|
75 | |
---|
76 | |
---|
77 | # = 2. Re-deploy drbl client = |
---|
78 | # == Cheange Xen Kernel == |
---|
79 | Xen_Kernel=$(cat $Work_Home/etc/Xen_Kernel) |
---|
80 | #read -p "Xen_Kernel=$Xen_Kernel" |
---|
81 | echo "/opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel" |
---|
82 | /opt/drbl/sbin/drblsrv-offline -s $Xen_Kernel |
---|
83 | echo "" |
---|
84 | # == Re-delpoy drbl client == |
---|
85 | echo "Re-delpoy drbl client" |
---|
86 | echo "/opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf" |
---|
87 | /opt/drbl/sbin/drblpush -c /etc/drbl/drblpush.conf |
---|
88 | echo "" |
---|