diff --git a/files/keepalive.exit.sh b/files/keepalive.exit.sh deleted file mode 100644 index 19c28dc..0000000 --- a/files/keepalive.exit.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Version 1.6 -# Parameter setzen -GATEWAY1ext=185.66.193.105 -GATEWAY2ext=185.66.193.106 -GATEWAY1=10.188.255.5 -GATEWAY2=10.188.255.6 -GATEWAY1v6=2a03:2260:121::255:5 -GATEWAY2v6=2a03:2260:121::255:6 -IP=/sbin/ip -PING=/bin/ping -BATCTL=/usr/local/sbin/batctl - -#if [ "hostname = troisdorf1 | troisdorf2" ] -if [ $(hostname) = "troisdorf1" ] || [ $(hostname) = "troisdorf2" ] - then - DEFAULT_GATEWAY=$GATEWAY1 - DEFAULT_GATEWAYext=$GATEWAY1ext - FALLBACK_GATEWAY=$GATEWAY2 - FALLBACK_GATEWAYext=$GATEWAY2ext - DEFAULT_GATEWAYv6=$GATEWAY1v6 - FALLBACK_GATEWAYv6=$GATEWAY2v6 - else - DEFAULT_GATEWAY=$GATEWAY2 - DEFAULT_GATEWAYext=$GATEWAY2ext - FALLBACK_GATEWAY=$GATEWAY1 - FALLBACK_GATEWAYext=$GATEWAY1ext - DEFAULT_GATEWAYv6=$GATEWAY2v6 - FALLBACK_GATEWAYv6=$GATEWAY1v6 - -fi - -if $PING -c 1 $DEFAULT_GATEWAYext - then - $IP route replace default via $DEFAULT_GATEWAY table 42 - $IP -6 route replace default via $DEFAULT_GATEWAYv6 table 42 - $BATCTL gw server 100Mbit/100Mbit - echo "Gateway erreichbar" - else - if $PING -c 1 $FALLBACK_GATEWAYext - then - $IP route replace default via $FALLBACK_GATEWAY table 42 - $IP -6 route replace default via $FALLBACK_GATEWAYv6 table 42 - $BATCTL gw server 80Mbit/80Mbit - echo "Nun FALLBACK_GATEWAY" - else - $BATCTL gw off - #Kein Gateway erreichbar, batctl gw off - fi -fi - diff --git a/files/keepalive.exit.sh.j2 b/files/keepalive.exit.sh.j2 index 6a4443c..a99b670 100644 --- a/files/keepalive.exit.sh.j2 +++ b/files/keepalive.exit.sh.j2 @@ -1,10 +1,29 @@ -#!/bin/bash +#!/bin/sh +# +# -q quiet +# -c nb of pings -ping -q -I {{ sn_ffrl_IPv4 }} 8.8.8.8 -c 4 -i 1 -W 5 >/dev/null 2>&1 +HOST1=8.8.8.8 +HOST2=8.8.4.4 +BATCTL=/usr/local/sbin/batctl -if test $? -eq 0; then - /usr/local/sbin/batctl gw server 100Mbit/100Mbit +ping -q -c5 $HOST1 > /dev/null +if [ $? -eq 0 ] +then + echo "ok" + $BATCTL gw server 100Mbit/100Mbit else - /usr/local/sbin/batctl gw off + + echo "$HOST1 NICHT ok" + ping -q -c5 $HOST2 > /dev/null + if [ $? -eq 0 ] + then + echo "$HOST2 ok" + $BATCTL gw server 100Mbit/100Mbit + else + echo "$HOST2 NICHT ok" + $BATCTL gw off + fi + fi diff --git a/install.sn.yml b/install.sn.yml index eba6c99..d836102 100644 --- a/install.sn.yml +++ b/install.sn.yml @@ -9,7 +9,7 @@ user: root gather_facts: False vars: - snversion: master_v2.9000001_beta + snversion: master_v3.0.0 batmanversion: v2015.2 common_required_packages: - git @@ -192,21 +192,18 @@ with_items: logrotate_config - name: Create freifunk directory file: path=/opt/freifunk state=directory mode=0755 - - name: Check gateway / keepalive script + - name: Check gateway / keepalive script supernode copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500 with_items: check_gw_script register: check_gw when: sn_exit is undefined - - - name: Check gateway / keepalive script + - name: Check gateway / keepalive script super- and exitnode template: src=./files/keepalive.exit.sh.j2 dest=/opt/freifunk/keepalive.sh owner=root group=root mode=0500 register: check_gw when: sn_exit is defined - - name: Add cron job with check gateway script cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root" when: check_gw.changed - - name: Tunneldigger stats copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500 with_items: tunneld_stats_file @@ -215,8 +212,6 @@ - name: Add cron job tunneldigger stats cron: name=tunneld_stats job="/opt/freifunk/collectd_td_stat.sh > /dev/null 2>&1" user="root" when: tunneld_stats.changed - - - name: Copy dhcpd template file template: src=./files/dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf owner=root group=root mode=0444 register: dhcpd @@ -235,23 +230,24 @@ cron: name=backbone special_time=reboot job="/opt/freifunk/l2tp_backbone.sh" - name: Add cron startup script cron: name=startup special_time=reboot job="/opt/freifunk/sn_startup.sh" - - name: Copy backbone script template: src=./files/l2tp_backbone.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544 when: sn_exit is undefined - name: Copy backbone script template: src=./files/l2tp_backbone.sh.exit.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544 when: sn_exit is defined - - name: Collectd template file template: src=./files/collectd.conf.j2 dest=/etc/collectd/collectd.conf owner=root group=root mode=0444 register: collectd - name: Restart collectd service: name=collectd state=restarted when: collectd.changed - - name: configure startup script + - name: configure startup script supernode template: src=./files/sn_startup.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500 when: sn_exit is undefined + - name: Exit node startup script super- and exitnode + template: src=./files/sn_startup.exit.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500 + when: sn_exit is defined - name: SSH authorized_keys copy: src=./files/{{ item }} dest=/root/.ssh owner=root group=root mode=0400 with_items: authorized_keys @@ -271,9 +267,6 @@ - name: Interface configuration with ffrl gre tunnel copy: src=./files/interfaces-{{ sn_hostname }} dest=/etc/network/interfaces owner=root group=root mode=0544 when: sn_exit is defined - - name: Exit node startup script - template: src=./files/sn_startup.exit.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500 - when: sn_exit is defined - apt: update_cache=yes - name: Install bird apt: state=installed pkg=bird