123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- node_status_file="/etc/freifunk/status"
- new_state="off"
- force_offline="false"
- if [ -f "${node_status_file}" ]; then
- status=$(cat "${node_status_file}")
- if [ "${status}" != "active" ]; then
- force_offline="true"
- fi
- fi
- if ! systemctl status isc-dhcp-server >/dev/null; then
- force_offline="true"
- fi
- if ip route show | grep "^default via 10.132." -q; then
- new_state="server"
- fi
- if [ "${force_offline}" = "true" ]; then
- new_state="off"
- fi
- mesh_if_param="-m"
- if batctl -h 2>&1 | grep -q "meshif"; then
- mesh_if_param="meshif"
- fi
- for iface in $(ip -br l | awk '/^bat-/ { print $1 }'); do
- # Ignore any external BATMAN instance, if present
- if echo "${iface}" | grep -q '-ext$'; then
- continue
- fi
- old_state="$(batctl "${mesh_if_param}" "${iface}" gw_mode | awk '{ print $1 }')"
- if [ "$old_state" = "$new_state" ]; then
- # Nothing to do here, carry on
- continue
- fi
- # Set new values
- batctl "${mesh_if_param}" "${iface}" gw_mode "${new_state}"
- logger "B.A.T.M.A.N. gateway mode changed from ${old_state} to ${new_state} on ${iface}"
- done
|