Skip to content

Instantly share code, notes, and snippets.

@n0ts
Created April 18, 2012 02:11
Show Gist options
  • Save n0ts/2410585 to your computer and use it in GitHub Desktop.
Save n0ts/2410585 to your computer and use it in GitHub Desktop.
/etc/xen/scripts/network-bridge-custom
#!/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