Add L2TP backbone script for ffswitch server
This commit is contained in:
parent
9f47bd1274
commit
7d7ce7fc03
56
files/l2tp_backbone_ffswitch.sh.j2
Normal file
56
files/l2tp_backbone_ffswitch.sh.j2
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Version 5
|
||||||
|
# Der servername muss mit einer einstelligen Zahl aufhoeren!!!!!
|
||||||
|
communityname="troisdorf"
|
||||||
|
server="troisdorf0 troisdorf1 troisdorf2 troisdorf3 troisdorf4 troisdorf5 troisdorf6 troisdorf7 troisdorf8 troisdorf9"
|
||||||
|
#server="troisdorf0 {{ sn_hostname }}"
|
||||||
|
domain="freifunk-troisdorf.de"
|
||||||
|
mtu=1400
|
||||||
|
# community MAC address, without the last Byte (:)!
|
||||||
|
communitymacaddress="a2:8c:ae:6f:f6"
|
||||||
|
tunnelPrefix=10
|
||||||
|
sessionPrefix=1
|
||||||
|
# Netzwerkteil des Netzes, ohne abschliessenden Punkt
|
||||||
|
communitynetwork="10.188"
|
||||||
|
# IPv6 network
|
||||||
|
communitynetworkv6="fda0:747e:ab29:7405:255::"
|
||||||
|
# Drittes Octet des serverbereichs
|
||||||
|
octet3rd="255"
|
||||||
|
# CIDR muss /16 sein
|
||||||
|
localserver=$(/bin/hostname)
|
||||||
|
batadv=/usr/local/sbin/batadv-vis
|
||||||
|
alfred=/usr/local/sbin/alfred
|
||||||
|
batctl=/usr/local/sbin/batctl
|
||||||
|
ip=/sbin/ip
|
||||||
|
dig=/usr/bin/dig
|
||||||
|
|
||||||
|
for i in $server; do
|
||||||
|
(
|
||||||
|
for j in $server; do
|
||||||
|
if [ $i != $j ]; then
|
||||||
|
if [ $i = $localserver ]; then
|
||||||
|
ip l2tp add tunnel remote $($dig +short $j.$domain) local $(/bin/hostname -I | /usr/bin/cut -f1 -d' ') tunnel_id $tunnelPrefix${i#$communityname}${j#$communityname} peer_tunnel_id $tunnelPrefix${j#$communityname}${i#$communityname} encap udp udp_sport 300${i#$communityname}${j#$communityname} udp_dport 300${j#$communityname}${i#$communityname}
|
||||||
|
ip l2tp add session name l2tp-$j tunnel_id $tunnelPrefix${i#$communityname}${j#$communityname} session_id $sessionPrefix${i#$communityname}${j#$communityname} peer_session_id $sessionPrefix${j#$communityname}${i#$communityname}
|
||||||
|
#ip link set address $communitymacaddress:${i#$communityname}${j#$communityname} dev l2tp-$j
|
||||||
|
ip link set dev l2tp-$j mtu $mtu
|
||||||
|
ip link set up l2tp-$j
|
||||||
|
$batctl if add l2tp-$j
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
done
|
||||||
|
|
||||||
|
# Rest starten
|
||||||
|
$ip link set address $communitymacaddress:0${localserver#$communityname} dev bat0
|
||||||
|
#$ip link set address $communitymacaddress:ff dev bat0
|
||||||
|
$ip link set up dev bat0
|
||||||
|
$ip addr add $communitynetwork.$octet3rd.${localserver#$communityname}/16 broadcast $communitynetwork.255.255 dev bat0
|
||||||
|
$ip -6 addr add $communitynetworkv6${localserver#$communityname}/64 dev bat0
|
||||||
|
|
||||||
|
/usr/bin/killall alfred
|
||||||
|
/usr/bin/killall batadv-vis
|
||||||
|
/bin/sleep 5
|
||||||
|
$alfred -i bat0 > /dev/null 2>&1 &
|
||||||
|
/bin/sleep 15
|
||||||
|
$batadv -i bat0 -s > /dev/null 2>&1 &
|
@ -9,7 +9,8 @@
|
|||||||
user: root
|
user: root
|
||||||
gather_facts: False
|
gather_facts: False
|
||||||
vars:
|
vars:
|
||||||
snversion: master_v1.4
|
snversion: master_v1.7
|
||||||
|
batmanversion: v2015.2
|
||||||
common_required_packages:
|
common_required_packages:
|
||||||
- git
|
- git
|
||||||
- make
|
- make
|
||||||
@ -124,8 +125,11 @@
|
|||||||
dest=/tmp/batman-adv
|
dest=/tmp/batman-adv
|
||||||
when: aptupdates.changed
|
when: aptupdates.changed
|
||||||
register: getbatman
|
register: getbatman
|
||||||
|
- name: Get batman-adv no rebrotcast patch
|
||||||
|
get_url: url=http://map.freifunk-moehne.de/stuff/1001-batman-adv-introduce-no_rebroadcast-option.patch dest=/tmp/batman-adv/1001-batman-adv-introduce-no_rebroadcast-option.patch
|
||||||
- name: Install batman-adv
|
- name: Install batman-adv
|
||||||
shell: cd /tmp/batman-adv && git checkout master && make && make install
|
shell: cd /tmp/batman-adv && git checkout {{ batmanversion }} && make && make install
|
||||||
|
# shell: cd /tmp/batman-adv && git checkout {{ batmanversion }} && git apply 1001-batman-adv-introduce-no_rebroadcast-option.patch && make && make install
|
||||||
when: getbatman.changed
|
when: getbatman.changed
|
||||||
- name: Get batctl
|
- name: Get batctl
|
||||||
git: repo=http://git.open-mesh.org/batctl.git
|
git: repo=http://git.open-mesh.org/batctl.git
|
||||||
@ -133,7 +137,7 @@
|
|||||||
when: aptupdates.changed
|
when: aptupdates.changed
|
||||||
register: getbatctl
|
register: getbatctl
|
||||||
- name: Install batctl
|
- name: Install batctl
|
||||||
shell: cd /tmp/batctl && git checkout v2015.1 && make && make install
|
shell: cd /tmp/batctl && git checkout {{ batmanversion }} && make && make install
|
||||||
when: getbatctl.changed
|
when: getbatctl.changed
|
||||||
- name: Get alfred
|
- name: Get alfred
|
||||||
git: repo=http://git.open-mesh.org/alfred.git
|
git: repo=http://git.open-mesh.org/alfred.git
|
||||||
@ -141,13 +145,14 @@
|
|||||||
when: aptupdates.changed
|
when: aptupdates.changed
|
||||||
register: getalfred
|
register: getalfred
|
||||||
- name: Install alfred
|
- name: Install alfred
|
||||||
shell: cd /tmp/alfred && git checkout master && make && make install
|
shell: cd /tmp/alfred && git checkout {{ batmanversion }} && make && make install
|
||||||
when: getalfred.changed
|
when: getalfred.changed
|
||||||
- name: Get Tunneldigger
|
- name: Get Tunneldigger
|
||||||
git: repo=https://github.com/wlanslovenija/tunneldigger.git
|
git: repo=https://github.com/wlanslovenija/tunneldigger.git
|
||||||
dest=/srv/tunneldigger
|
dest=/srv/tunneldigger
|
||||||
register: tunneldigger
|
register: tunneldigger
|
||||||
when: aptupdates.changed
|
when: aptupdates.changed
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Configure tunneldigger
|
- name: Configure tunneldigger
|
||||||
command: "{{item}}"
|
command: "{{item}}"
|
||||||
with_items:
|
with_items:
|
||||||
@ -185,17 +190,25 @@
|
|||||||
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: check_gw_script
|
with_items: check_gw_script
|
||||||
register: check_gw
|
register: check_gw
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Add cron job with check gateway script
|
- name: Add cron job with check gateway script
|
||||||
cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root"
|
cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root"
|
||||||
when: check_gw.changed
|
when: check_gw.changed
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Copy dhcpd template file
|
- name: Copy dhcpd template file
|
||||||
template: src=./files/dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf owner=root group=root mode=0444
|
template: src=./files/dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf owner=root group=root mode=0444
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Add cron backbone script
|
- name: Add cron backbone script
|
||||||
cron: name=backbone special_time=reboot job="/opt/freifunk/l2tp_backbone.sh"
|
cron: name=backbone special_time=reboot job="/opt/freifunk/l2tp_backbone.sh"
|
||||||
- name: Add cron startup script
|
- name: Add cron startup script
|
||||||
cron: name=startup special_time=reboot job="/opt/freifunk/sn_startup.sh"
|
cron: name=startup special_time=reboot job="/opt/freifunk/sn_startup.sh"
|
||||||
- name: Copy backbone script
|
- name: Copy backbone script
|
||||||
template: src=./files/l2tp_backbone.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544
|
template: src=./files/l2tp_backbone.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544
|
||||||
|
when: ffswitch is undefined
|
||||||
|
- name: Copy backbone script
|
||||||
|
template: src=./files/l2tp_backbone_ffswitch.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544
|
||||||
|
when: ffswitch is defined
|
||||||
|
register: ffswitchl2tp
|
||||||
- name: Collectd template file
|
- name: Collectd template file
|
||||||
template: src=./files/collectd.conf.j2 dest=/etc/collectd/collectd.conf owner=root group=root mode=0444
|
template: src=./files/collectd.conf.j2 dest=/etc/collectd/collectd.conf owner=root group=root mode=0444
|
||||||
register: collectd
|
register: collectd
|
||||||
@ -210,12 +223,16 @@
|
|||||||
- name: Copy secondary zone file
|
- name: Copy secondary zone file
|
||||||
copy: src=./files/{{ item }} dest=/etc/bind owner=root group=bind mode=644
|
copy: src=./files/{{ item }} dest=/etc/bind owner=root group=bind mode=644
|
||||||
with_items: bind_zone_fftdf
|
with_items: bind_zone_fftdf
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Bind9, activate fftdf zone
|
- name: Bind9, activate fftdf zone
|
||||||
lineinfile: dest=/etc/bind/named.conf line='include "/etc/bind/named.conf.fftdf";' state=present
|
lineinfile: dest=/etc/bind/named.conf line='include "/etc/bind/named.conf.fftdf";' state=present
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Copy option template
|
- name: Copy option template
|
||||||
template: src=./files/named.conf.options.j2 dest=/etc/bind/named.conf.options owner=root group=bind mode=644
|
template: src=./files/named.conf.options.j2 dest=/etc/bind/named.conf.options owner=root group=bind mode=644
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Copy radvd config template
|
- name: Copy radvd config template
|
||||||
template: src=./files/radvd.conf.j2 dest=/etc/radvd.conf owner=radvd group=root mode=0444
|
template: src=./files/radvd.conf.j2 dest=/etc/radvd.conf owner=radvd group=root mode=0444
|
||||||
|
when: ffswitch is undefined
|
||||||
- name: Alfed message
|
- name: Alfed message
|
||||||
template: src=./files/alfred.sh.j2 dest=/opt/freifunk/alfred.sh owner=root group=root mode=0544
|
template: src=./files/alfred.sh.j2 dest=/opt/freifunk/alfred.sh owner=root group=root mode=0544
|
||||||
- name: Add cron job with alfred info script
|
- name: Add cron job with alfred info script
|
||||||
@ -226,6 +243,7 @@
|
|||||||
poll: 0
|
poll: 0
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
when: tunneldigger.changed
|
when: tunneldigger.changed
|
||||||
|
when: ffswitchl2tp.changed
|
||||||
- name: Wirte version information
|
- name: Wirte version information
|
||||||
shell: touch /etc/sn_version && echo {{ snversion }} > /etc/sn_version
|
shell: touch /etc/sn_version && echo {{ snversion }} > /etc/sn_version
|
||||||
- name: waiting for server to come back
|
- name: waiting for server to come back
|
||||||
|
Loading…
Reference in New Issue
Block a user