source: drbl-virt/sbin/duplicate_del_MAC @ 187

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

BugFix?: some install error

  • Property svn:executable set to *
File size: 748 bytes
Line 
1#!/bin/bash
2# Program:
3#   Delete duplicating VM MAC
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
17# Delete duplating VM MAC
18for vm_mac in $(echo $VM_MACs)
19do
20    vm_mac_lines=$(cat -n $1 | grep $vm_mac | awk '{print $1}' )
21    # no duplicated vlaue, doesn't do it
22    if [ -n $vm_mac_lines ]; then
23        vm_mac_count=$(echo $vm_mac_lines | wc -w)
24
25        for (( i=1; i<=${VM_mac_count}; i++ ))
26        do
27            del_line=$(echo $vm_mac_lines | cut -d " " -f${i})
28            sed -i "${del_line}d" $1
29        done
30    fi
31done
32 
33
Note: See TracBrowser for help on using the repository browser.