Merge branch 'master' into rojoka-patch-1
Conflicts: install.sn.yml
This commit is contained in:
commit
9c1574a451
@ -23,9 +23,9 @@ iface eth0 inet dhcp
|
|||||||
post-up iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
post-up iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||||
allow-hotplug eth1
|
allow-hotplug eth1
|
||||||
iface eth1 inet6 static
|
iface eth1 inet6 static
|
||||||
address 2a01:4f8:161:62a9::5
|
address 2a01:4f8:172:f4b::5
|
||||||
netmask 64
|
netmask 64
|
||||||
gateway 2a01:4f8:161:62a9::2
|
gateway 2a01:4f8:172:f4b::2
|
||||||
|
|
||||||
# GRE Tunnel zum Rheinland Backbone
|
# GRE Tunnel zum Rheinland Backbone
|
||||||
# - Die Konfigurationsdaten werden vom Rheinland Backbone vergeben und zugewiesen
|
# - Die Konfigurationsdaten werden vom Rheinland Backbone vergeben und zugewiesen
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo 0 > /tmp/sn_online
|
/usr/local/sbin/batctl gw off
|
||||||
$BATCTL gw off
|
|
||||||
/usr/sbin/service bird6 stop
|
/usr/sbin/service bird6 stop
|
||||||
/usr/sbin/service bird stop
|
/usr/sbin/service bird stop
|
||||||
/usr/sbin/service tunneldigger stop
|
/usr/sbin/service tunneldigger stop
|
||||||
/usr/sbin/service radvd stop
|
/usr/sbin/service radvd stop
|
||||||
/usr/sbin/service isc-dhcp-server stop
|
/usr/sbin/service isc-dhcp-server stop
|
||||||
while [ true ] ; do
|
while [ true ] ; do
|
||||||
online=$(/bin/cat /tmp/sn_online)
|
online=$(/bin/cat /etc/supernode-status/supernode.status)
|
||||||
|
mode=$(/bin/cat /etc/supernode-status/supernode.mode)
|
||||||
iam=$(/bin/hostname)
|
iam=$(/bin/hostname)
|
||||||
day=$(date +%d)
|
day=$(date +%d)
|
||||||
BATCTL=/usr/local/sbin/batctl
|
BATCTL=/usr/local/sbin/batctl
|
||||||
@ -15,10 +15,9 @@ while [ true ] ; do
|
|||||||
# Names of the 2 Supernodes #
|
# Names of the 2 Supernodes #
|
||||||
SN1=troisdorf5
|
SN1=troisdorf5
|
||||||
SN2=troisdorf6
|
SN2=troisdorf6
|
||||||
# Default Supernode if loadbalance=0 or day > 15 #
|
active_SN=$(/bin/hostname)
|
||||||
active_SN=$SN2
|
|
||||||
# Turn loadbalance on/off #
|
# Turn loadbalance on/off #
|
||||||
loadbalance=1
|
loadbalance=$(cat /etc/supernode-status/loadbalancing.mode)
|
||||||
##################
|
##################
|
||||||
# functions #
|
# functions #
|
||||||
# Supernode off #
|
# Supernode off #
|
||||||
@ -29,8 +28,12 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service tunneldigger stop
|
/usr/sbin/service tunneldigger stop
|
||||||
/usr/sbin/service radvd stop
|
/usr/sbin/service radvd stop
|
||||||
/usr/sbin/service isc-dhcp-server stop
|
/usr/sbin/service isc-dhcp-server stop
|
||||||
echo 0 > /tmp/sn_online
|
if [ $loadbalance == 1 ] && [ $mode != 0 ]; then
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo 3 > /etc/supernode-status/supernode.status
|
||||||
|
else
|
||||||
|
echo 0 > /etc/supernode-status/supernode.status
|
||||||
|
fi
|
||||||
|
echo "collectd.gateways.troisdorf5.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Supernode on #
|
# Supernode on #
|
||||||
supernode_on () {
|
supernode_on () {
|
||||||
@ -40,8 +43,12 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service tunneldigger start
|
/usr/sbin/service tunneldigger start
|
||||||
/usr/sbin/service radvd start
|
/usr/sbin/service radvd start
|
||||||
/usr/sbin/service isc-dhcp-server start
|
/usr/sbin/service isc-dhcp-server start
|
||||||
echo 1 > /tmp/sn_online
|
if [ $loadbalance == 1 ]; then
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo 1 > /etc/supernode-status/supernode.status
|
||||||
|
else
|
||||||
|
echo 2 > /etc/supernode-status/supernode.status
|
||||||
|
fi
|
||||||
|
echo "collectd.gateways.troisdorf5.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# Restart Services #
|
# Restart Services #
|
||||||
supernode_fail () {
|
supernode_fail () {
|
||||||
@ -51,11 +58,11 @@ while [ true ] ; do
|
|||||||
/usr/sbin/service tunneldigger restart
|
/usr/sbin/service tunneldigger restart
|
||||||
/usr/sbin/service radvd restart
|
/usr/sbin/service radvd restart
|
||||||
/usr/sbin/service isc-dhcp-server restart
|
/usr/sbin/service isc-dhcp-server restart
|
||||||
echo 0 > /tmp/sn_online
|
echo 0 > /etc/supernode-status/supernode.status
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.troisdorf5.sn-status $online `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
}
|
}
|
||||||
# who am i ? #
|
# who am i ? #
|
||||||
if [ $iam == troisdorf5 ]
|
if [ $iam = "troisdorf5" ];
|
||||||
then
|
then
|
||||||
my_SN_IP=185.66.193.105
|
my_SN_IP=185.66.193.105
|
||||||
other_SN_IP=185.66.193.106
|
other_SN_IP=185.66.193.106
|
||||||
@ -65,20 +72,22 @@ while [ true ] ; do
|
|||||||
other_SN_IP=185.66.193.105
|
other_SN_IP=185.66.193.105
|
||||||
other_SN_IP_EXTERN=5.9.76.198
|
other_SN_IP_EXTERN=5.9.76.198
|
||||||
fi
|
fi
|
||||||
if [ $loadbalance == 1 ]
|
if [ $loadbalance = "1" ] && [ $mode != "0" ];
|
||||||
then
|
then
|
||||||
if [ $day -gt 15 ]
|
if [ $day -gt 15 ]
|
||||||
then
|
then
|
||||||
active_SN=$SN1
|
active_SN=$SN1
|
||||||
|
else
|
||||||
|
active_SN=$SN2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#Check other Supernode
|
#Check other Supernode
|
||||||
if [ $iam != $active_SN ]
|
if [ $iam != $active_SN ];
|
||||||
then
|
then
|
||||||
ping -q -c5 $other_SN_IP -I eth0 > /dev/null
|
ping -q -c5 $other_SN_IP -I eth0 > /dev/null
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online == 1 ]; then
|
if [ $online ==1 ] || [ $online = 2 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Aktiver Supernode wieder online. Ich habe mich wieder ausgeschaltet", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
supernode_off
|
supernode_off
|
||||||
@ -89,10 +98,11 @@ while [ true ] ; do
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Check this Supernode
|
# Check this Supernode
|
||||||
|
if [ $mode != "0" ]; then
|
||||||
ping -q -c5 $my_SN_IP -I eth0 > /dev/null
|
ping -q -c5 $my_SN_IP -I eth0 > /dev/null
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
if [ $online == 0 ]; then
|
if [ $online = 0 ] || [ $online = 3 ]; then
|
||||||
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich bin jetzt Supernode!", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":white_check_mark:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
supernode_on
|
supernode_on
|
||||||
@ -101,13 +111,20 @@ while [ true ] ; do
|
|||||||
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
curl -X POST --data-urlencode 'payload={"text": "Ich konnte mich selbst nicht anpingen. Ich versuche mal die Services neu zu starten", "channel": "#technik", "username": "{{ sn_hostname }}", "icon_emoji": ":warning:"}' https://hooks.slack.com/services/{{ slack_token }}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [ $mode = "0" ]; then
|
||||||
|
supernode_off
|
||||||
|
|
||||||
|
fi
|
||||||
for service in bird bird6 isc-dhcp-server radvd python named
|
for service in bird bird6 isc-dhcp-server radvd python named
|
||||||
do
|
do
|
||||||
x=`pidof $service`;
|
x=`pidof $service`;
|
||||||
if [ "$x" == "" ]; then
|
if [ "$x" = "" ]; then
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.$service 0 `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.troisdorf5.$service 0 `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
|
echo 0 > /etc/supernode-status/"$service".status
|
||||||
else
|
else
|
||||||
echo "collectd.gateways.{{ sn_hostname }}.$service 1 `date +%s`" | nc -q 0 10.188.1.27 2003
|
echo "collectd.gateways.troisdorf5.$service 1 `date +%s`" | nc -q 0 10.188.1.27 2003
|
||||||
|
echo 1 > /etc/supernode-status/"$service".status
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
sleep 60
|
sleep 60
|
||||||
|
52
files/supernode
Normal file
52
files/supernode
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
help () {
|
||||||
|
echo "Supernode Settings:"
|
||||||
|
echo "status | off | loadbalance"
|
||||||
|
}
|
||||||
|
|
||||||
|
status () {
|
||||||
|
supernode_status=$(/bin/cat /etc/supernode-status/supernode.status)
|
||||||
|
supernode_mode=$(/bin/cat /etc/supernode-status/supernode.mode)
|
||||||
|
loadbalancing=$(cat /etc/supernode-status/loadbalancing.mode)
|
||||||
|
|
||||||
|
echo "Supernode Status: (Ist-Zustand)"
|
||||||
|
if [ $supernode_status == 0 ]; then
|
||||||
|
echo "Supernode ist Offline"
|
||||||
|
elif [ $supernode_status == 1 ]; then
|
||||||
|
echo "Supernode läuft (Loadbalancing)"
|
||||||
|
elif [ $supernode_status == 2 ]; then
|
||||||
|
echo "Supernode läuft (Dauer-Ein)"
|
||||||
|
elif [ $supernode_status == 3 ]; then
|
||||||
|
echo "Supernode Offline (Loadbalancing)"
|
||||||
|
fi
|
||||||
|
if [ $loadbalancing = 1 ]; then
|
||||||
|
echo "Loadbalancing ist Aktiv"
|
||||||
|
else
|
||||||
|
echo "Loadbalancing ist Deativiert"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
off () {
|
||||||
|
echo 0 > /etc/supernode-status/supernode.mode
|
||||||
|
echo "Supernode Deaktiviert"
|
||||||
|
}
|
||||||
|
|
||||||
|
on () {
|
||||||
|
echo 1 > /etc/supernode-status/supernode.mode
|
||||||
|
echo "Supernode Aktiviert"
|
||||||
|
}
|
||||||
|
|
||||||
|
loadbalance () {
|
||||||
|
loadbalancing=$(cat /etc/supernode-status/loadbalancing.mode)
|
||||||
|
if ! [ -f /etc/supernode-status/loadbalancing.mode ]; then
|
||||||
|
echo 0 > /etc/supernode-status/loadbalancing.mode
|
||||||
|
fi
|
||||||
|
if [ $loadbalancing == 0 ]; then
|
||||||
|
echo 1 > /etc/supernode-status/loadbalancing.mode
|
||||||
|
else
|
||||||
|
echo 0 > /etc/supernode-status/loadbalancing.mode
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
status
|
||||||
|
}
|
||||||
|
$1
|
@ -9,7 +9,11 @@
|
|||||||
user: root
|
user: root
|
||||||
gather_facts: False
|
gather_facts: False
|
||||||
vars:
|
vars:
|
||||||
|
<<<<<<< HEAD
|
||||||
snversion: master_v3.0.7
|
snversion: master_v3.0.7
|
||||||
|
=======
|
||||||
|
snversion: master_v3.0.8
|
||||||
|
>>>>>>> master
|
||||||
batmanversion: v2015.2
|
batmanversion: v2015.2
|
||||||
common_required_packages:
|
common_required_packages:
|
||||||
- git
|
- git
|
||||||
@ -196,6 +200,9 @@
|
|||||||
- name: Add cron job with check gateway script
|
- name: Add cron job with check gateway script
|
||||||
cron: name=check_gw special_time=reboot job="/opt/freifunk/keepalive.sh > /dev/null 2>&1 &" user="root"
|
cron: name=check_gw special_time=reboot job="/opt/freifunk/keepalive.sh > /dev/null 2>&1 &" user="root"
|
||||||
when: check_gw.changed
|
when: check_gw.changed
|
||||||
|
- name: Supernode Config script super- and exitnode
|
||||||
|
copy: src=./files/supernode dest=/usr/bin/supernode owner=root group=root mode=0500
|
||||||
|
when: sn_exit is defined
|
||||||
- name: Tunneldigger stats
|
- name: Tunneldigger stats
|
||||||
copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500
|
copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500
|
||||||
with_items: tunneld_stats_file
|
with_items: tunneld_stats_file
|
||||||
@ -270,7 +277,7 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- net.ipv4.netfilter.ip_conntrack_generic_timeout = 240
|
- net.ipv4.netfilter.ip_conntrack_generic_timeout = 240
|
||||||
- net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 54000
|
- net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 54000
|
||||||
- net.netfilter.nf_conntrack_max = 262144
|
- net.netfilter.nf_conntrack_max = 65536
|
||||||
- name: check modprobe.conf
|
- name: check modprobe.conf
|
||||||
stat: path=/etc/modprobe.conf
|
stat: path=/etc/modprobe.conf
|
||||||
register: modprobe1
|
register: modprobe1
|
||||||
|
Loading…
Reference in New Issue
Block a user