###### Network Setting
check="n"
echo -n "4. Network Setting Start ? [y/n] Default [n] : "
read check
if [ $check = "y" ];then
network_bonding_mode="1"
network_miimon_time="100"
# echo -n "Server is vmware ? [y/n] :"
# read vmware_check
echo -n "Server Hostname ? :"
read network_hostname
echo -n "Network Bonding Name ? : "
read network_bonding_name
echo -n "Slave First Device ? : "
read network_slave_first_device
echo -n "Slave Second Device ? : "
read network_slave_second_device
echo -n "Ip address ? : "
read network_ip
echo -n "Subnetmask ? : "
read network_mask
echo -n "Gateway ? : "
read network_gateway
echo -n "MTU ? : "
read network_mtu
HWADDR_0=`ifconfig -a | grep -i $network_slave_first_device | grep HWaddr | awk '{print $5}'`
HWADDR_1=`ifconfig -a | grep -i $network_slave_second_device | grep HWaddr | awk '{print $5}'`
echo "
###########################################################
HOSTNAME : $network_hostname
Bonding Name : $network_bonding_name
Bondimg Mode : $network_bonding_mode
Miimon Time : $network_miimon_time
First Device : $network_slave_first_device $HWADDR_0
Second Device : $network_slave_second_device $HWADDR_1
IP ADDRESS : $network_ip
NetMask : $network_mask
Gateway : $network_gateway
MTU : $network_mtu
###########################################################"
echo -n "Bonding Setup Start? [y/n]"
read check
if [ $check = "y" ];then
echo "alias $network_bonding_name bonding" >> /etc/modprobe.d/bonding.conf
echo "DEVICE=$network_bonding_name
BOOTPROTO=static
IPADDR=$network_ip
NETMASK=$network_mask
onBOOT=yes
USERCTL=no
NM_ConTROLLED=no
BONDING_OPTS=\"mode=$network_bonding_mode miimon=$network_miimon_time\"" > /etc/sysconfig/network-scripts/ifcfg-$network_bonding_name
if ! [ -z $network_mtu ];then
echo "MTU=$network_mtu" >> /etc/sysconfig/network-scripts/ifcfg-$network_bonding_name
fi
if ! [ -z $network_gateway ];then
echo "GATEWAY=$network_gateway" >> /etc/sysconfig/network-scripts/ifcfg-$network_bonding_name
fi
for ethernet in `echo $network_slave_first_device $network_slave_second_device`
do
HWADDR=`ifconfig -a | grep -i $ethernet | grep HWaddr | awk '{print $5}'`
echo "DEVICE=$ethernet
BOOTPROTO=none
HWADDR=$HWADDR
onBOOT=yes
USERCTL=no
MASTER=$network_bonding_name
NM_ConTROLLED=no
SLAVE=yes" > /etc/sysconfig/network-scripts/ifcfg-$ethernet
done
if ! [ -z $network_hostname];then
echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
$network_ip $network_hostname
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6" > /etc/hosts
echo "NETWORKING=yes
HOSTNAME=$network_hostname" > /etc/sysconfig/network
hostname $network_hostname
fi
service network stop
modprobe $network_bonding_name
service network restart
echo "Network Bonding Setup Suscess"
fi
fi