source: drbl-virt/sbin/duplicate_del_MAC @ 189

Last change on this file since 189 was 189, checked in by rock, 14 years ago

Bugfix:

  • Property svn:executable set to *
File size: 773 bytes
RevLine 
[185]1#!/bin/bash
2# Program:
[187]3#   Delete duplicating VM MAC
[185]4# Author:
5#   Rock {waue, shunfa, rock}@nchc.org.tw
6# Version:
7#    1.0
8# History:
9#   2010/08/26  Rock    First release (1.0)
10
11# 刪掉空白行
12#sed -i '/^$/d' "$1"
13
14#read -p "cp - f $1 ${1}.old ; $?"
15cp $1 $1.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak
16
[189]17read -p "debug $VM_MACs"
[187]18# Delete duplating VM MAC
19for vm_mac in $(echo $VM_MACs)
[185]20do
[187]21    vm_mac_lines=$(cat -n $1 | grep $vm_mac | awk '{print $1}' )
[185]22    # no duplicated vlaue, doesn't do it
[187]23    if [ -n $vm_mac_lines ]; then
24        vm_mac_count=$(echo $vm_mac_lines | wc -w)
[185]25
[187]26        for (( i=1; i<=${VM_mac_count}; i++ ))
[185]27        do
[187]28            del_line=$(echo $vm_mac_lines | cut -d " " -f${i})
[185]29            sed -i "${del_line}d" $1
30        done
31    fi
32done
33 
34
Note: See TracBrowser for help on using the repository browser.