Ignore:
Timestamp:
Aug 26, 2010, 5:24:32 PM (14 years ago)
Author:
rock
Message:

BugFix?: some install error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/duplicate_del_MAC

    r185 r187  
    11#!/bin/bash
    22# Program:
    3 #   Delete duplicating ip & hostname
     3#   Delete duplicating VM MAC
    44# Author:
    55#   Rock {waue, shunfa, rock}@nchc.org.tw
     
    1515cp $1 $1.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak
    1616
    17 # Delete duplating VM IP
    18 for vm_ip in $(echo $VM_IPs)
     17# Delete duplating VM MAC
     18for vm_mac in $(echo $VM_MACs)
    1919do
    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}' )
    2121    # no duplicated vlaue, doesn't do it
    22     if [ -n $vm_ip_lines ]; then
    23         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)
    2424
    25         for (( i=1; i<=${VM_ip_count}; i++ ))
     25        for (( i=1; i<=${VM_mac_count}; i++ ))
    2626        do
    27             del_line=$(echo $vm_ip_lines | cut -d " " -f${i})
     27            del_line=$(echo $vm_mac_lines | cut -d " " -f${i})
    2828            sed -i "${del_line}d" $1
    2929        done
     
    3131done
    3232 
    33 # Dlete duplicating hostname in file
    34 for vm_host in $(echo $VM_hosts)
    35 do
    36     # line numbers
    37     vm_host_lines=$(cat -n $1 | grep "$vm_host" | awk '{print $1}')
    38     # no duplicated vlaue, doesn't do it
    39     if [ -n $vm_host_lines ]; then
    40         vm_host_count=$(echo $vm_host_lines | wc -w)
    41  
    42         for (( i=1; i<=${vm_host_count}; i++ ))
    43         do
    44             del_line=$(echo $vm_host_lines | cut -d " " -f${i})
    45             sed -i "${del_line}d" $1
    46         done                                                                                                                                                             
    47     fi
    48 done
    4933
Note: See TracChangeset for help on using the changeset viewer.