42 lines
797 B
Bash
Executable File
42 lines
797 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=1 max_bonds=1 miimon=100 downdelay=200 updelay=200 primary=eth0' >> /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
|
|
|
|
#change belong to netadmin
|
|
chown 98.98 ${IF_CONFIG}/ifcfg-bond0
|
|
chown 98.98 ${IF_CONFIG}/ifcfg-eth0
|
|
chown 98.98 ${IF_CONFIG}/ifcfg-eth2
|