Created
April 18, 2012 02:11
-
-
Save n0ts/2410585 to your computer and use it in GitHub Desktop.
/etc/xen/scripts/network-bridge-custom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Exit if anything goes wrong | |
set -e | |
# First arg is operation. | |
OP=$1 | |
shift | |
script=/etc/xen/scripts/network-bridge | |
exec_operation() | |
{ | |
sysconfig=/etc/sysconfig/network-scripts | |
if [ ! -d $sysconfig ]; then | |
return 1 | |
fi | |
ETH_LIST=`find $sysconfig -name ifcfg-[eth\|bond]*` | |
num=0 | |
for eth in $ETH_LIST | |
do | |
if [ $eth == "lo" ]; then | |
continue | |
fi | |
bootproto=`cat $eth | egrep "BOOTPROTO\=.*" | cut -d "=" -f 2` | |
if [ "$bootproto" == "none" ]; then | |
continue | |
fi | |
onboot=`cat $eth | egrep "ONBOOT\=.*" | cut -d "=" -f 2` | |
if [ "$onboot" == "no" ]; then | |
continue | |
fi | |
slave=`cat $eth | egrep "SLAVE\=.*" | cut -d "=" -f 2` | |
if [ "$slave" == "yes" ]; then | |
continue | |
fi | |
netdev=`cat $eth | egrep "DEVICE\=.*" | cut -d "=" -f 2` | |
$script $1 vifnum=$num bridge=xenbr$num netdev=$netdev | |
num=`expr $num + 1` | |
done | |
} | |
case ${OP} in | |
start) | |
exec_operation $OP | |
;; | |
stop) | |
exec_operation $OP | |
;; | |
status) | |
exec_operation $OP | |
;; | |
*) | |
echo 'Unknown command: ' ${OP} | |
echo 'Valid command are: start, stop, status' | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment