#!/bin/bash
if [ $# -lt 8 ];then
echo "Usage: $0 <bond*> <eth*> <eth*> <eth*> <eth*> <ipaddress> <netmask> <gateway>"
echo "eg: $0 bond0 eth0 eth1 eth2 eth3 10.0.0.1 255.255.255.0 10.0.0.254"
exit 1
fi
echo "DEVICE=$1
IPADDR=$6
NETMASK=$7
GATEWAY=$8
ONBOOT=yes
BOOTPROTO=none
USERCTL=no" >/tmp/ifcfg-$1
mv -f /tmp/ifcfg-$1 /etc/sysconfig/network-scripts/
echo "DEVICE=$2
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$2
mv -f /tmp/ifcfg-$2 /etc/sysconfig/network-scripts/
echo "DEVICE=$3
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$3
mv -f /tmp/ifcfg-$3 /etc/sysconfig/network-scripts/
echo "DEVICE=$4
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$4
mv -f /tmp/ifcfg-$4 /etc/sysconfig/network-scripts/
echo "DEVICE=$5
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$5
mv -f /tmp/ifcfg-$5 /etc/sysconfig/network-scripts/
echo " alias bond0 bonding
options bond0 mode=6 miimon=100
" > /etc/modprobe.d/bonding.conf
/etc/init.d/network restart
if [ $# -lt 8 ];then
echo "Usage: $0 <bond*> <eth*> <eth*> <eth*> <eth*> <ipaddress> <netmask> <gateway>"
echo "eg: $0 bond0 eth0 eth1 eth2 eth3 10.0.0.1 255.255.255.0 10.0.0.254"
exit 1
fi
echo "DEVICE=$1
IPADDR=$6
NETMASK=$7
GATEWAY=$8
ONBOOT=yes
BOOTPROTO=none
USERCTL=no" >/tmp/ifcfg-$1
mv -f /tmp/ifcfg-$1 /etc/sysconfig/network-scripts/
echo "DEVICE=$2
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$2
mv -f /tmp/ifcfg-$2 /etc/sysconfig/network-scripts/
echo "DEVICE=$3
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$3
mv -f /tmp/ifcfg-$3 /etc/sysconfig/network-scripts/
echo "DEVICE=$4
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$4
mv -f /tmp/ifcfg-$4 /etc/sysconfig/network-scripts/
echo "DEVICE=$5
USERCTL=no
ONBOOT=yes
MASTER=$1
SLAVE=yes
BOOTPROTO=none" >/tmp/ifcfg-$5
mv -f /tmp/ifcfg-$5 /etc/sysconfig/network-scripts/
echo " alias bond0 bonding
options bond0 mode=6 miimon=100
" > /etc/modprobe.d/bonding.conf
/etc/init.d/network restart