- Timestamp:
- Aug 19, 2010, 6:03:54 PM (14 years ago)
- Location:
- drbl-virt/sbin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/drbl_PXE_PV-VM_deploy.sh
r180 r181 31 31 Host_first_IP="" 32 32 Host_last_IP="" 33 get_Host_IP_range $eth33 get_Host_IP_range 34 34 # == Get VM number & IP range == 35 VM_IP_range="" 35 declare -i VM_IP_range="" 36 declare -i Host_last_IP_4="" 36 37 VM_first_IP="" 37 38 VM_last_IP="" 38 get_VM_IP_range $eth39 get_VM_IP_range 39 40 # == Get VM IP prefix hostname == 40 41 VM_prefix_name="" 41 get_VM_prefix_name $eth42 get_VM_prefix_name 42 43 44 43 45 done 46 44 47 45 48 -
drbl-virt/sbin/functions_drbl_virt
r180 r181 157 157 158 158 function get_DRBL_eth(){ 159 eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt | cut -d "-" -f2 | cut -d "." -f1)159 eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt$ | cut -d "-" -f2 | cut -d "." -f1) 160 160 eths_nu=$(echo $eths | wc -l) 161 161 … … 170 170 171 171 # get eth network 172 eth_address=$(/opt/drbl/bin/drbl-get-ipadd $ 1)173 eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $ 1)172 eth_address=$(/opt/drbl/bin/drbl-get-ipadd $eth) 173 eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $eth) 174 174 eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask) 175 175 eth_network_f3=$(echo $eth_network | cut -d "." -f 1-3) 176 176 177 177 IP_nu=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | wc -l) 178 Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==1 {print $1}" | awk '{print 1}')178 Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==1 {print $1}" | awk '{print $1}') 179 179 Host_last_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==$IP_nu {print $1}"| awk '{print $1}') 180 180 … … 183 183 function get_VM_IP_range(){ 184 184 echo "" 185 echo "DRBL client IP range -> $ 1[$Host_first_IP ~ $Host_last_IP]"185 echo "DRBL client IP range -> $eth [$Host_first_IP ~ $Host_last_IP]" 186 186 187 187 declare -i Host_last_IP_4=$(echo $Host_last_IP | cut -d "." -f4) … … 195 195 do 196 196 echo "" 197 echo "Input VM number/IP range in $ 1(ex. 40)."197 echo "Input VM number/IP range in $eth (ex. 40)." 198 198 read -p "(If you have 10 PCs(4-core), suggestion is 30): " VM_IP_range 199 199 read -p "Is it correct? (yes/no): " jude … … 209 209 do 210 210 echo "" 211 read -p "Input Prefix name for VM in $ 1(ex. drblvm): " VM_prefix_name211 read -p "Input Prefix name for VM in $eth (ex. drblvm): " VM_prefix_name 212 212 read -p "Is it correct? (yes/no): " jude 213 213 done … … 217 217 function create_VM_IP_table(){ 218 218 #/etc/drbl-virt/etc/IP_VM_eth 219 220 } 221 222 223 224 219 VM_prefix_eth=$(echo $eth | sed 's/eth//g') 220 declare -i VM_Host_totoal_nu=$((${Host_last_IP_4}-1+${VM_IP_range})) 221 if [ -e /opt/drbl-virt/etc/IP_VM_$eth ]; then 222 mv /opt/drbl-virt/etc/IP_VM_$eth /opt/drbl-virt/etc/IP_VM_${eth}.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak 223 fi 224 declare -i VM_IP_0=$VM_prefix_eth 225 declare -i VM_IP_1="" 226 declare -i VM_IP_2="" 227 declare -i VM_IP_3="" 228 229 230 # 2 bit 231 if [ $VM_Host_totoal_nu -lt 100 ]; then 232 for (( i=$Host_last_IP_4 ; i<="$VM_IP_range" ; i++ )) 233 do 234 if [ $i -lt 10 ]; then 235 VM_IP_1=0 236 VM_IP_2=$i 237 echo "${eth_network_f3}.$VM_IP_2 ${VM_prefix_name}${VM_IP_0}${VM_IP_1}${VM_IP_2}" >> /opt/drbl-virt/etc/IP_VM_$eth 238 else 239 VM_IP_1=$i 240 echo "${eth_network_f3}.$VM_IP_1 ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$et 241 fi 242 done 243 # 3 bit 244 elif [ $VM_Host_totoal_nu -ge 100 ] && [ $VM_Host_totoal_nu -lt 254 ]; then 245 for (( i=$Host_last_IP_4 ; i<=$VM_IP_range ; i++ )) 246 do 247 if [ $i -lt 10 ]; then 248 VM_IP_1=0 249 VM_IP_2=0 250 VM_IP_3=$i 251 echo "${eth_network_f3}.${VM_IP_3} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}${VM_IP_2}${VM_IP_3}" >> /opt/drbl-virt/etc/IP_VM_$eth 252 elif [ $i -lt 100 ]; then 253 VM_IP_1=0 254 VM_IP_2=$i 255 echo "${eth_network_f3}.${VM_IP_2} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}${VM_IP_2}" >> /opt/drbl-virt/etc/IP_VM_$eth 256 else 257 VM_IP_1=$i 258 echo "${eth_network_f3}.${VM_IP_1} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$eth 259 fi 260 261 done 262 263 fi 264 } 265 266 267 268
Note: See TracChangeset
for help on using the changeset viewer.