gluon/package/gluon-alt-esc-client/files/usr/sbin/altesc-update
Linus Lüssing 3d6cd44629 gluon-alt-esc: add client + provider package
The client package allows to create a new wifi interface with direct access
to the local Freifunk network but with alternative exit gateways for internet
connectivity. A custom ESSID can be chosen.

The provider package is the counterpart to the client package and
configures the firewall of the selected Gluon node to grant permission to
route packets between the client and wan zone.

Note that the Gluon Alt-ESC provider package is not mandatory for the
Gluon Alt-ESC client package. In fact, any client device in the mesh network
can be chosen and configured to provide internet access for the Alt-ESC
client package.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
2018-11-15 02:10:03 +01:00

35 lines
906 B
Bash
Executable File

#!/bin/sh
disabled=`uci get gluon-alt-esc-client.@client[0].disabled`
if [ ! "$disabled" = "0" ]; then
ebtables-tiny -t nat -F ALT_ESC_STDGW
exit 0
fi
get_gw_hosts() {
for gw in `batctl gwl -n -H | sed "s/.* \(..:..:..:..:..:..\) (.*/\1/"`; do
batctl tg -n -H | grep ".* ..:..:..:..:..:.. .* $gw"
done | sed "s/^.* \(..:..:..:..:..:..\) .* ..:..:..:..:..:.. .*/\1/" | sort
}
gwhosts="`get_gw_hosts`"
gwhostssum="`echo "$gwhosts" | md5sum`"
oldgwhosts="`cat /var/run/gluon-alt-esc.hosts 2> /dev/null`"
oldgwhostssum="`cat /var/run/gluon-alt-esc.hosts.md5sum 2> /dev/null`"
if [ "$gwhostssum" = "$oldgwhostssum" ]; then
echo "Stayed the same"
exit 0
fi
ebtables-tiny -t nat -F ALT_ESC_STDGW
for host in $gwhosts; do
ebtables-tiny -t nat -A ALT_ESC_STDGW -d "$host" -j ALT_ESC_DNAT
done
echo "$gwhosts" > /var/run/gluon-alt-esc.hosts
echo "$gwhostssum" > /var/run/gluon-alt-esc.hosts.md5sum