Update and rename subnet-down.tmpl to subnet-down

This commit is contained in:
Manevolent 2023-04-13 00:06:35 -06:00 committed by GitHub
parent ade0914def
commit 271b982bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 17 deletions

24
tinc/subnet-down Normal file
View File

@ -0,0 +1,24 @@
#!/bin/ash
echo "Route down: $SUBNET weight $WEIGHT via $NODE ($REMOTEADDRESS:$REMOTEPORT)"
nonMACChars=`echo $SUBNET | tr -d "[:digit:]" | tr -d [:ABCDEFabcdef]`
date=`date -u`
if [ -z "$nonMACChars" ]; then
# This subnet is a MAC
rm -f /tmp/tinc_peer_mac_$NODE_$SUBNET
else
# This subnet is an IP address
if echo "$SUBNET" | grep -q -E ".+/32$"; then
address=`echo "$SUBNET" | cut -d '/' -f 1`
rm -f /tmp/tinc_peer_mac_$NODE_$address
if arp -an | grep -q "\($address\)"; then
echo "Unmapping $addresss
fi
fi
fi
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
$SCRIPTPATH/check-node

View File

@ -1,17 +0,0 @@
#!/bin/ash
echo "Route down: \$SUBNET weight \$WEIGHT via \$NODE (\$REMOTEADDRESS:\$REMOTEPORT)"
nonMACChars=`echo \$SUBNET | tr -d "[:digit:]" | tr -d [:ABCDEFabcdef]`
date=`date -u`
if [ -z "\$nonMACChars" ]; then
# This subnet is a MAC
rm /tmp/tinc_peer_mac_\$NODE_\$SUBNET
else
# This subnet is an IP address
if echo "\$SUBNET" | grep -q -E ".+/32\$"; then
address=`echo "\$SUBNET" | cut -d '/' -f 1`
rm /tmp/tinc_peer_mac_\$NODE_\$address
fi
fi
./check-node