Commit 6bb5d03f authored by Joanne Hugé's avatar Joanne Hugé

playbook/ors: fix configure-re6st script (add interface option)

parent 1c75b1e4
#!/bin/bash #!/bin/bash
IF_LIST=()
RM_IF_LIST=()
CONF="/etc/re6stnet/re6stnet.conf" CONF="/etc/re6stnet/re6stnet.conf"
TMP="/tmp/re6stnet.conf.$(date +%s)" 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
RM_IF_LIST+=($IF);
fi
fi
done
cp $CONF $TMP;
REPLACE=0 REPLACE=0
# Check if configuration is correct
for IF in "${IF_LIST[@]}"; do cp $CONF $TMP;
for IF in $(ls -1 /sys/class/net/ | grep -v "^lo\|^re6stnet\|^slap"); do
if ! grep -q "^interface $IF" $TMP; then if ! grep -q "^interface $IF" $TMP; then
REPLACE=1 REPLACE=1
fi fi
done done
for IF in "${RM_IF_LIST[@]}"; do
if grep -q "^interface $IF" $TMP; then echo $REPLACE
REPLACE=1
fi
done
# Reconfigure re6st if configuration not correct # Reconfigure re6st if configuration not correct
if (( $REPLACE )); then if (( $REPLACE )); then
sed -i '/^interface/d' $TMP sed -i '/^interface/d' $TMP
for IF in "${IF_LIST[@]}"; do for IF in $(ls -1 /sys/class/net/ | grep -v "^lo\|^re6stnet\|^slap"); do
echo "interface $IF" >> $TMP echo "interface $IF" >> $TMP
done done
mv $TMP $CONF; mv $TMP $CONF;
......
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