Commit f09dd0e5 authored by Joanne Hugé's avatar Joanne Hugé

playbook/ors: improve configure-re6st script

parent 954aaacf
Pipeline #27808 passed with stage
in 0 seconds
#!/bin/bash
if ip -6 a show dev enp0s31f6 | grep -q fe80; then
IFACE="enp0s31f6"
elif ip -6 a show dev enp2s0 | grep -q fe80; then
IFACE="enp2s0"
else
exit;
fi
IF_LIST=()
RM_IF_LIST=()
CONF="/etc/re6stnet/re6stnet.conf"
sed -i '/^interface/d' $CONF
# Don't run re6st with interface option at Lille Office
if ping6 -q -c2 -w3 fe80::20d:b9ff:fe3f:9055%$IFACE; then
if ps -ax -o cmd | grep babeld | grep -q $IFACE; then
systemctl restart re6stnet;
TMP="/tmp/re6stnet.conf.$(date +%s)"
cd /sys/class/net;
for IF in $(find . -type l -printf "%f\n"); do
# If interface is virtual
if ! realpath $(readlink $IF) | grep -q "^/sys/devices/virtual"; then
# If interface is up and has IPv6 neighbours
if [ "$(cat $IF/operstate)" = "up" ] && [ -n "$(ip -6 neigh list dev $IF)" ]; then
# Special case: interfaces connected to Lille office LAN should not have interface option enabled
if ! ping6 -q -c3 -w3 fe80::20d:b9ff:fe3f:9055%$IF; then
IF_LIST+=($IF);
else
RM_IF_LIST+=($IF);
fi
fi
fi
done
cp $CONF $TMP;
REPLACE=0
# Check if configuration is correct
for IF in "${IF_LIST[@]}"; do
if ! grep -q "^interface $IF" $TMP; then
REPLACE=1
fi
else
echo "interface $IFACE" >> $CONF
if ! ps -ax -o cmd | grep babeld | grep -q $IFACE; then
systemctl restart re6stnet;
done
for IF in "${RM_IF_LIST[@]}"; do
if grep -q "^interface $IF" $TMP; then
REPLACE=1
fi
done
# Reconfigure re6st if configuration not correct
if (( $REPLACE )); then
sed -i '/^interface/d' $TMP
for IF in "${IF_LIST[@]}"; do
echo "interface $IF" >> $TMP
done
mv $TMP $CONF;
systemctl restart re6stnet
fi
rm -rf $TMP;
......@@ -43,6 +43,6 @@ with open('/opt/upgrader/configure-slapos.log', 'w+') as l:
l.write("[configure-slapos] slapos.cfg not valid\n")
# Delete slaptun devices
for i in range(0,19):
subprocess.run(['ip', 'link', 'delete', 'slaptun'])
subprocess.run(['ip', 'link', 'delete', 'slaptun{}'.format(i)])
subprocess.run(['rm', '-f', '/opt/slapos/slapos.xml'], check=True)
subprocess.run(['slapos', 'node', 'format', '--now'], check=True, capture_output=True)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment