#!/bin/bash # # Check if this system (still) is a gateway and update mesh mode if necessary (Salt managed) # # Rewritten by: Maximilian Wilhelm # -- Sat, 07 Mar 2015 23:21:53 +0100 # # Default to "off" new_state="off" # # If there is a default route via an IP from our address space # we assume that this gateway has an internet connection. As a # default route would be propagated in via iBGP and/or OSPF it # will only be present if at least one border router has an up # and running connection to AS201701. if ip route show | grep "^default via 10.132." -q; then new_state="server" fi # Make sure the following glob isn't interpreted as a literal string if there isn't # any meshable interface. shopt -s nullglob for mesh_int in /sys/class/net/*/mesh; do old_state="$(cat ${mesh_int}/gw_mode)" [ "$old_state" == "$new_state" ] && continue echo "${new_state}" > "${mesh_int}/gw_mode" echo "54MBit/54MBit" > "${mesh_int}/gw_bandwidth" logger "B.A.T.M.A.N. gateway mode changed from ${old_state} to ${new_state} on ${mesh_int}" done