Changeset 187 for drbl-virt/sbin/duplicate_del_MAC
- Timestamp:
- Aug 26, 2010, 5:24:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/duplicate_del_MAC
r185 r187 1 1 #!/bin/bash 2 2 # Program: 3 # Delete duplicating ip & hostname3 # Delete duplicating VM MAC 4 4 # Author: 5 5 # Rock {waue, shunfa, rock}@nchc.org.tw … … 15 15 cp $1 $1.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak 16 16 17 # Delete duplating VM IP18 for vm_ ip in $(echo $VM_IPs)17 # Delete duplating VM MAC 18 for vm_mac in $(echo $VM_MACs) 19 19 do 20 vm_ ip_lines=$(cat -n $1 | grep $vm_ip| awk '{print $1}' )20 vm_mac_lines=$(cat -n $1 | grep $vm_mac | awk '{print $1}' ) 21 21 # no duplicated vlaue, doesn't do it 22 if [ -n $vm_ ip_lines ]; then23 vm_ ip_count=$(echo $vm_ip_lines | wc -w)22 if [ -n $vm_mac_lines ]; then 23 vm_mac_count=$(echo $vm_mac_lines | wc -w) 24 24 25 for (( i=1; i<=${VM_ ip_count}; i++ ))25 for (( i=1; i<=${VM_mac_count}; i++ )) 26 26 do 27 del_line=$(echo $vm_ ip_lines | cut -d " " -f${i})27 del_line=$(echo $vm_mac_lines | cut -d " " -f${i}) 28 28 sed -i "${del_line}d" $1 29 29 done … … 31 31 done 32 32 33 # Dlete duplicating hostname in file34 for vm_host in $(echo $VM_hosts)35 do36 # line numbers37 vm_host_lines=$(cat -n $1 | grep "$vm_host" | awk '{print $1}')38 # no duplicated vlaue, doesn't do it39 if [ -n $vm_host_lines ]; then40 vm_host_count=$(echo $vm_host_lines | wc -w)41 42 for (( i=1; i<=${vm_host_count}; i++ ))43 do44 del_line=$(echo $vm_host_lines | cut -d " " -f${i})45 sed -i "${del_line}d" $146 done47 fi48 done49 33
Note: See TracChangeset
for help on using the changeset viewer.