forked from freifunk-franken/firmware
Einrückungen Korrigiert
Signed-off-by: Jan-Tarek Butt <buttjantarek@googlemail.com>
This commit is contained in:
parent
8468b4c130
commit
f6fe4f81c5
|
@ -9,78 +9,78 @@ test_internet_host1="mastersword.de"
|
||||||
test_internet_host2="109.163.229.254"
|
test_internet_host2="109.163.229.254"
|
||||||
|
|
||||||
if [ "$SERVER" == "no" ]; then
|
if [ "$SERVER" == "no" ]; then
|
||||||
test -f /tmp/started || exit
|
test -f /tmp/started || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Only do something with fastd when the router has internet connection
|
#Only do something with fastd when the router has internet connection
|
||||||
if ping -w5 -c3 "$test_internet_host1" &>/dev/null ||
|
if ping -w5 -c3 "$test_internet_host1" &>/dev/null ||
|
||||||
ping -w5 -c3 "$test_internet_host2" &>/dev/null ||
|
ping -w5 -c3 "$test_internet_host2" &>/dev/null ||
|
||||||
ping6 -w5 -c3 heise.de &>/dev/null; then
|
ping6 -w5 -c3 heise.de &>/dev/null; then
|
||||||
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
||||||
if [ "$SERVER" == "no" ]; then
|
if [ "$SERVER" == "no" ]; then
|
||||||
hostname=$(cat /proc/sys/kernel/hostname)
|
hostname=$(cat /proc/sys/kernel/hostname)
|
||||||
|
|
||||||
if [ "$hostname" == "OpenWrt" ]; then
|
if [ "$hostname" == "OpenWrt" ]; then
|
||||||
hostname=""
|
hostname=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$hostname" == "" ]; then
|
if [ "$hostname" == "" ]; then
|
||||||
hostname=$mac
|
hostname=$mac
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
hostname=$SERVERNAME
|
hostname=$SERVERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /etc/fastd ]; then
|
if [ ! -d /etc/fastd ]; then
|
||||||
mkdir /etc/fastd
|
mkdir /etc/fastd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /etc/fastd/$project ]; then
|
if [ ! -d /etc/fastd/$project ]; then
|
||||||
mkdir /etc/fastd/$project
|
mkdir /etc/fastd/$project
|
||||||
|
|
||||||
mkdir /tmp/fastd_${project}_peers
|
mkdir /tmp/fastd_${project}_peers
|
||||||
ln -s /tmp/fastd_${project}_peers /etc/fastd/$project/peers
|
ln -s /tmp/fastd_${project}_peers /etc/fastd/$project/peers
|
||||||
echo "#!/bin/sh" > /etc/fastd/$project/up.sh
|
echo "#!/bin/sh" > /etc/fastd/$project/up.sh
|
||||||
echo "ip link set up dev ${project}VPN" >> /etc/fastd/$project/up.sh
|
echo "ip link set up dev ${project}VPN" >> /etc/fastd/$project/up.sh
|
||||||
echo "batctl if add ${project}VPN" >> /etc/fastd/$project/up.sh
|
echo "batctl if add ${project}VPN" >> /etc/fastd/$project/up.sh
|
||||||
chmod +x /etc/fastd/$project/up.sh
|
chmod +x /etc/fastd/$project/up.sh
|
||||||
|
|
||||||
secret=$(fastd --generate-key 2>&1 | grep -i secret | awk '{ print $2 }')
|
|
||||||
echo "include peers from \"/etc/fastd/$project/peers\";" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "log to syslog level warn;" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "method \"null\";" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
# http://lists.nord-west.net/pipermail/freifunk-ol-dev/2013-July/000322.html
|
|
||||||
# echo "bind 0.0.0.0:10000;" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "interface \"${project}VPN\";" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "mtu 1426;" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "secret \"$secret\";" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
echo "on up \"/etc/fastd/${project}/up.sh\";" >> /etc/fastd/${project}/${project}.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /tmp/fastd_${project}_peers ]; then
|
secret=$(fastd --generate-key 2>&1 | grep -i secret | awk '{ print $2 }')
|
||||||
mkdir /tmp/fastd_${project}_peers
|
echo "include peers from \"/etc/fastd/$project/peers\";" >> /etc/fastd/${project}/${project}.conf
|
||||||
fi
|
echo "log to syslog level warn;" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
echo "method \"null\";" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
# http://lists.nord-west.net/pipermail/freifunk-ol-dev/2013-July/000322.html
|
||||||
|
# echo "bind 0.0.0.0:10000;" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
echo "interface \"${project}VPN\";" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
echo "mtu 1426;" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
echo "secret \"$secret\";" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
echo "on up \"/etc/fastd/${project}/up.sh\";" >> /etc/fastd/${project}/${project}.conf
|
||||||
|
fi
|
||||||
|
|
||||||
pubkey=$(fastd -c /etc/fastd/$project/$project.conf --show-key --machine-readable)
|
if [ ! -d /tmp/fastd_${project}_peers ]; then
|
||||||
#port=666
|
mkdir /tmp/fastd_${project}_peers
|
||||||
|
fi
|
||||||
|
|
||||||
|
pubkey=$(fastd -c /etc/fastd/$project/$project.conf --show-key --machine-readable)
|
||||||
|
# port=666
|
||||||
|
|
||||||
|
|
||||||
# fire up
|
# fire up
|
||||||
if [ "$(/sbin/ifconfig -a | grep -i ethernet | grep $project)" == "" ]; then
|
if [ "$(/sbin/ifconfig -a | grep -i ethernet | grep $project)" == "" ]; then
|
||||||
/bin/rm /var/run/fastd.$project.pid
|
/bin/rm /var/run/fastd.$project.pid
|
||||||
fastd -c /etc/fastd/$project/$project.conf -d --pid-file /var/run/fastd.$project.pid
|
fastd -c /etc/fastd/$project/$project.conf -d --pid-file /var/run/fastd.$project.pid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# register
|
# register
|
||||||
wget -T15 "http://mastersword.de/~reddog/${project}/?mac=$mac&name=$hostname&port=$port&key=$pubkey" -O /tmp/fastd_${project}_output
|
wget -T15 "http://mastersword.de/~reddog/${project}/?mac=$mac&name=$hostname&port=$port&key=$pubkey" -O /tmp/fastd_${project}_output
|
||||||
|
|
||||||
filenames=$(awk '/^####/ { gsub(/^####/, "", $0); gsub(/.conf/, "", $0); print $0; }' /tmp/fastd_${project}_output)
|
filenames=$(awk '/^####/ { gsub(/^####/, "", $0); gsub(/.conf/, "", $0); print $0; }' /tmp/fastd_${project}_output)
|
||||||
for file in $filenames; do
|
for file in $filenames; do
|
||||||
awk "{ if(a) print }; /^####$file.conf$/{a=1}; /^$/{a=0};" /tmp/fastd_${project}_output > /etc/fastd/$project/peers/$file
|
awk "{ if(a) print }; /^####$file.conf$/{a=1}; /^$/{a=0};" /tmp/fastd_${project}_output > /etc/fastd/$project/peers/$file
|
||||||
done
|
done
|
||||||
|
|
||||||
#reload
|
#reload
|
||||||
kill -HUP $(cat /var/run/fastd.$project.pid)
|
kill -HUP $(cat /var/run/fastd.$project.pid)
|
||||||
else
|
else
|
||||||
echo "Der Router kann keine Verbindung zum Fastdserver aufbauen"
|
echo "Der Router kann keine Verbindung zum Fastdserver aufbauen"
|
||||||
echo "$0 macht nichts!"
|
echo "$0 macht nichts!"
|
||||||
|
|
Loading…
Reference in New Issue