2017-01-25 22:30:16 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source scan-netdev
|
|
|
|
|
|
|
|
modprobe bonding
|
|
|
|
|
2017-02-23 14:04:57 -06:00
|
|
|
# All vlans are using netmask /22
|
|
|
|
MASK=22
|
2017-01-25 22:30:16 -06:00
|
|
|
|
2021-09-07 05:24:08 -05:00
|
|
|
for VLAN in 110 218 222 226 306 321 480 ; do
|
2017-01-25 22:30:16 -06:00
|
|
|
if [[ -f /etc/netdev/vlan.$VLAN.csv ]] ; then
|
|
|
|
VLAN_CONF=`grep $SERVER_SERIAL \
|
|
|
|
/etc/netdev/vlan.$VLAN.csv`
|
|
|
|
fi
|
|
|
|
if [[ -z $VLAN_CONF ]] ; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
MY_HOSTNAME=`hostname`
|
|
|
|
#HOSTNAME,SERIAL,IP_ADDRESS,BOND,MODE,SLAVE0,SLAVE1
|
|
|
|
VLAN_HOSTNAME=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 1`
|
|
|
|
if [[ -n $VLAN_HOSTNAME ]] ; then
|
|
|
|
if [[ "$MY_HOSTNAME" != "$VLAN_HOSTNAME" ]] ; then
|
|
|
|
hostname $VLAN_HOSTNAME
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
VLAN_IP=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 3`
|
|
|
|
VLAN_BOND=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 4`
|
|
|
|
BOND_MODE=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 5`
|
|
|
|
SLAVE_0=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 6`
|
|
|
|
SLAVE_1=`echo $VLAN_CONF \
|
|
|
|
| cut -d ',' -f 7`
|
|
|
|
if [[ -z $VLAN_BOND ]] ; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [[ ! -d /sys/class/net/$VLAN_BOND ]] ; then
|
|
|
|
if [[ ! -f /sys/class/net/bonding_masters ]] ; then
|
|
|
|
echo "Missing bonding_masters special file"
|
|
|
|
exit 22
|
|
|
|
fi
|
|
|
|
echo "+$VLAN_BOND" \
|
|
|
|
> /sys/class/net/bonding_masters
|
|
|
|
sleep 3
|
|
|
|
if [[ ! -d /sys/class/net/$VLAN_BOND ]] ; then
|
|
|
|
echo "$VLAN_BOND not available"
|
|
|
|
exit 23
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
MY_MODE=`cat /sys/class/net/$VLAN_BOND/bonding/mode \
|
|
|
|
| cut -d ' ' -f 2`
|
|
|
|
if [[ "$MY_MODE" != "$BOND_MODE" ]] ; then
|
|
|
|
echo $BOND_MODE \
|
|
|
|
> /sys/class/net/$VLAN_BOND/bonding/mode
|
|
|
|
sleep 2
|
|
|
|
fi
|
|
|
|
ip link set $VLAN_BOND up
|
2017-02-23 14:04:57 -06:00
|
|
|
if [[ $BOND_MODE != 1 ]] ; then
|
2021-09-07 05:24:08 -05:00
|
|
|
ethtool -s $SLAVE_0 autoneg off speed 25000 duplex full
|
|
|
|
ethtool -s $SLAVE_1 autoneg off speed 25000 duplex full
|
2017-02-23 14:04:57 -06:00
|
|
|
fi
|
2017-01-25 22:30:16 -06:00
|
|
|
sleep 5
|
|
|
|
ifenslave $VLAN_BOND $SLAVE_0 $SLAVE_1
|
|
|
|
sleep 5
|
|
|
|
if [[ $BOND_MODE == 1 ]] ; then
|
|
|
|
ip addr add $VLAN_IP/$MASK dev $VLAN_BOND
|
|
|
|
else
|
|
|
|
ip link add link $VLAN_BOND \
|
|
|
|
name $VLAN_BOND.$VLAN \
|
|
|
|
type vlan id $VLAN
|
|
|
|
ip link set $VLAN_BOND.$VLAN up
|
|
|
|
ip addr add $VLAN_IP/$MASK dev $VLAN_BOND.$VLAN
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
systemctl restart sshd
|
|
|
|
|