Files
StateGrid/install_shell/set_bonding.sh
swei dac107a1da chown ifcfg-bond0,ifcfg-eth0,ifcfg-eth2 to netadmin
modified:   set_bonding.sh

    Signed-off-by: swei <swei@linx-info.com>
2014-05-07 14:53:27 +08:00

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