Files
StateGrid/install_shell/set_bonding.sh
swei b46436f532 simplify the code
modified:   set_bonding.sh

	Signed-off-by: swei <swei@linx-info.com>
2014-03-27 16:13:10 +08:00

39 lines
612 B
Bash
Executable File

#!/bin/sh
export LANG=c
create_ifcfg(){
for i in $@;
do
cat > ${IF_CONFIG}/ifcfg-eth${i} <<EOF
DEVICE=eth${i}
BOOTPROTO=none
SERVICE=ipv4-static
MASTER=bond0
SLAVE=yes
HWADDR=
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
EOF
done
}
IF_CONFIG="/etc/sysconfig/network-devices"
if [ -f ${IF_CONFIG}/ifcfg-bond0 ];then
echo "bonding exit.."
else
if ! grep -q "^bonding" /etc/sysconfig/modules;then
echo 'bonding mode=6 max_bonds=1' >> /etc/sysconfig/modules
fi
mv ${IF_CONFIG}/ifcfg-eth0 ${IF_CONFIG}/ifcfg-bond0
sed -i "s/^DEVICE=eth0/DEVICE=bond0/g" ${IF_CONFIG}/ifcfg-bond0
create_ifcfg 0 2
fi