2020-02-05 17:18:21 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e -x -a
|
|
|
|
|
|
|
|
# Run once
|
|
|
|
if [ -z "$eth10g" -o -z "$eth1g" ]; then
|
|
|
|
|
|
|
|
### Check host variables
|
|
|
|
if [ -z "$play_host" -o -z "$node_name" -o -z "$int_ip" ]; then
|
|
|
|
echo "play_host/node_name/int_ip not specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Find 1G and 10G network interfaces (10G is used for keepalived and galera)
|
|
|
|
eth10g=
|
|
|
|
eth1g=
|
|
|
|
export $(ssh root@$play_host '
|
|
|
|
for i in /sys/class/net/*; do
|
|
|
|
ip link set ${i##/sys/class/net/} up
|
|
|
|
if [ x`cat /sys/class/net/enp4s0/carrier 2>/dev/null` == "x1" ]; then
|
|
|
|
if [ x`cat $i/speed 2>/dev/null` == "x10000" ]; then
|
|
|
|
echo eth10g=${i##/sys/class/net/}
|
|
|
|
elif [ x`cat $i/speed 2>/dev/null` == "x1000" ]; then
|
|
|
|
echo eth1g=${i##/sys/class/net/}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done')
|
|
|
|
|
|
|
|
if [ -z "$eth10g" ]; then
|
|
|
|
echo "10GbE network not found on $play_host"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Configure network
|
|
|
|
envsubst < ./etc/rc.local.env | ssh root@$play_host 'cat > /etc/rc.local'
|
|
|
|
envsubst < ./etc/network/interfaces.env | ssh root@$play_host 'cat > /etc/network/interfaces.new'
|
|
|
|
ssh root@$play_host <<EOF
|
2020-02-28 21:15:12 +03:00
|
|
|
set -e -x
|
2020-02-05 17:18:21 +03:00
|
|
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" \
|
|
|
|
-o Dpkg::Options::="--force-confold" install -y \
|
2020-02-28 21:15:12 +03:00
|
|
|
bridge-utils resolvconf
|
2020-02-05 17:18:21 +03:00
|
|
|
|
|
|
|
chmod 755 /etc/rc.local
|
|
|
|
/etc/rc.local
|
|
|
|
systemctl enable rc-local
|
|
|
|
if ! cmp -s /etc/network/interfaces /etc/network/interfaces.new; then
|
2020-02-28 21:15:12 +03:00
|
|
|
nmcli dev disconnect $eth1g || true
|
2020-02-05 17:18:21 +03:00
|
|
|
mv /etc/network/interfaces.new /etc/network/interfaces
|
|
|
|
ifup br0
|
|
|
|
service networking restart
|
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# -z eth10g / eth1g
|
|
|
|
fi
|