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

playbook/ors: improve configure-re6st script

parent 954aaacf
#!/bin/bash #!/bin/bash
if ip -6 a show dev enp0s31f6 | grep -q fe80; then IF_LIST=()
IFACE="enp0s31f6" RM_IF_LIST=()
elif ip -6 a show dev enp2s0 | grep -q fe80; then
IFACE="enp2s0"
else
exit;
fi
CONF="/etc/re6stnet/re6stnet.conf" CONF="/etc/re6stnet/re6stnet.conf"
sed -i '/^interface/d' $CONF TMP="/tmp/re6stnet.conf.$(date +%s)"
# Don't run re6st with interface option at Lille Office cd /sys/class/net;
if ping6 -q -c2 -w3 fe80::20d:b9ff:fe3f:9055%$IFACE; then for IF in $(find . -type l -printf "%f\n"); do
if ps -ax -o cmd | grep babeld | grep -q $IFACE; then # If interface is virtual
systemctl restart re6stnet; 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 fi
else done
echo "interface $IFACE" >> $CONF for IF in "${RM_IF_LIST[@]}"; do
if ! ps -ax -o cmd | grep babeld | grep -q $IFACE; then if grep -q "^interface $IF" $TMP; then
systemctl restart re6stnet; REPLACE=1
fi 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 fi
rm -rf $TMP;
...@@ -43,6 +43,6 @@ with open('/opt/upgrader/configure-slapos.log', 'w+') as l: ...@@ -43,6 +43,6 @@ with open('/opt/upgrader/configure-slapos.log', 'w+') as l:
l.write("[configure-slapos] slapos.cfg not valid\n") l.write("[configure-slapos] slapos.cfg not valid\n")
# Delete slaptun devices # Delete slaptun devices
for i in range(0,19): 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(['rm', '-f', '/opt/slapos/slapos.xml'], check=True)
subprocess.run(['slapos', 'node', 'format', '--now'], check=True, capture_output=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