#!/bin/bash # Django : 2020-12-15 # Check connectivity to supernode HTTP_STATUS_CODE=(`curl --silent --interface wg-welt --get --ipv6 --connect-timeout 5 --write-out '%{http_code}' --output /dev/null 'http://[fe80::27c:16ff:fec0:6c74]:80'`) if [ ${HTTP_STATUS_CODE} != "200" ]; then logger -t checkuplink "curl --silent --interface wg-welt --get --ipv6 --connect-timeout 5 --write-out '%{http_code}' --output /dev/null 'http://[fe80::27c:16ff:fec0:6c74]:80' faild with HTTP-errorcode: ${HTTP_STATUS_CODE}" logger -t checkuplink "... better we restart the wireguard-tunnel!" ip link set nomaster bat-welt dev vxlan-mesh &> /dev/null ip link del dev mesh-vpn &> /dev/null ip link del wg-welt &> /dev/null systemctl stop wg-quick@wg-welt systemctl restart networking logger -t checkuplink "Sending public-key to the broker." /usr/bin/wget -q -O- --post-data='{"domain":"ffmuc_welt","public_key":"HjDRCwE4Q7UPAKXrmM4s6VOgMK+HJZCixWTaVC8KiRU="}' http://broker.ffmuc.net/api/v1/wg/key/exchange logger -t checkuplink "Starting wireguard-daemon." systemctl start wg-quick@wg-welt logger -t checkuplink "Starting vxlan-meshing." vxlan else #logger -t checkuplink "wiregurad-tunnel is up an running : HTTP-statuscode: ${HTTP_STATUS_CODE}" fi