From 4b9075738bf6d8a8c7230e636fc288158689a910 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Jan 2018 12:35:18 +0000 Subject: [PATCH 1/3] Adding mesh support for OLSR2 --- src/freedombone-image-customise | 46 +++++++++++++++++++++++++++++++++ src/freedombone-image-mesh | 4 +++ src/freedombone-mesh-batman | 13 +++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 7d556522..92b6460c 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -125,6 +125,9 @@ ENABLE_ZERONET= MESH_TEXT_EDITOR='pluma' +OLSR2_REPO="https://github.com/OLSR/OONF" +OLSR2_COMMIT='81033251c4ee1c5699bfee9d2985112c6266ab0a' + BMX6_REPO="https://github.com/bmx-routing/bmx6" BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181' @@ -668,6 +671,48 @@ mesh_shutdown_script() { chroot "$rootdir" systemctl enable meshshutdown } +install_olsr2() { + chroot "$rootdir" apt-get -yq install cmake libnl-3-dev + + git clone $OLSR2_REPO $rootdir/etc/olsr2 + + cat < $rootdir/usr/bin/install_olsr2 +#!/bin/bash +cd /etc/olsr2 +git checkout $OLSR2_COMMIT -b $OLSR2_COMMIT +cd /etc/olsr2/build +cmake .. +make +make install +EOF + chroot "$rootdir" chmod +x /usr/bin/install_olsr2 + chroot "$rootdir" /usr/bin/install_olsr2 + + if [ ! -f /usr/local/sbin/olsrd2_static ]; then + echo $'Unable to build OLSR2' + exit 79835392 + fi + + rm $rootdir/usr/bin/install_olsr2 + + echo '[Unit]' > $rootdir/etc/systemd/system/olsr2.service + echo 'Description=OLSR2 mesh routing protocol' >> $rootdir/etc/systemd/system/olsr2.service + echo 'Requires=network.target' >> $rootdir/etc/systemd/system/olsr2.service + echo 'After=network.target' >> $rootdir/etc/systemd/system/olsr2.service + echo '' >> $rootdir/etc/systemd/system/olsr2.service + echo '[Service]' >> $rootdir/etc/systemd/system/olsr2.service + echo 'Type=forking' >> $rootdir/etc/systemd/system/olsr2.service + echo 'User=root' >> $rootdir/etc/systemd/system/olsr2.service + echo 'Group=root' >> $rootdir/etc/systemd/system/olsr2.service + echo 'ExecStart=/usr/local/sbin/olsrd2_static wlan0' >> $rootdir/etc/systemd/system/olsr2.service + echo 'ExecStop=/usr/bin/kill -15 $MAINPID' >> $rootdir/etc/systemd/system/olsr2.service + echo 'PIDFile=/var/run/olsr2/pid' >> $rootdir/etc/systemd/system/olsr2.service + echo 'Restart=on-failure' >> $rootdir/etc/systemd/system/olsr2.service + echo '' >> $rootdir/etc/systemd/system/olsr2.service + echo '[Install]' >> $rootdir/etc/systemd/system/olsr2.service + echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/olsr2.service +} + install_bmx6() { git clone $BMX6_REPO $rootdir/etc/bmx6 @@ -853,6 +898,7 @@ initialise_mesh() { install_batman install_bmx6 install_bmx7 + install_olsr2 mesh_shutdown_script install_vpn install_tomb diff --git a/src/freedombone-image-mesh b/src/freedombone-image-mesh index 6df71311..f4a86eaa 100755 --- a/src/freedombone-image-mesh +++ b/src/freedombone-image-mesh @@ -1423,6 +1423,10 @@ if [ -f $MESH_INSTALL_SETUP ]; then systemctl disable bmx7 echo $'BMX7 disabled' >> $INSTALL_LOG + systemctl stop olsr2 + systemctl disable olsr2 + echo $'OLSR2 disabled' >> $INSTALL_LOG + #tomb slam all tmp_ram_disk 100 enable_predictable_device_names diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index a5a3efcb..71d0ac2f 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -71,8 +71,10 @@ function stop { systemctl stop bmx6 systemctl stop bmx7 + systemctl stop olsr2 systemctl disable bmx6 systemctl disable bmx7 + systemctl disable olsr2 systemctl stop dnsmasq systemctl disable dnsmasq @@ -206,6 +208,7 @@ function start { sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE}|g" /etc/systemd/system/bmx6.service sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE}|g" /etc/systemd/system/bmx7.service + sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE}|g" /etc/systemd/system/olsr2.service systemctl daemon-reload add_wifi_interface $IFACE $WIFI_SSID ad-hoc $CHANNEL @@ -229,6 +232,7 @@ function start { sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service + sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service systemctl daemon-reload else echo $"$EIFACE is not connected" @@ -255,11 +259,18 @@ function start { if grep -q "bmx6" $MESH_DEFAULT_PROTOCOL; then systemctl enable bmx6 systemctl restart bmx6 - else + fi + + if grep -q "bmx7" $MESH_DEFAULT_PROTOCOL; then systemctl enable bmx7 systemctl restart bmx7 fi + if grep -q "olsr" $MESH_DEFAULT_PROTOCOL; then + systemctl enable olsr2 + systemctl restart olsr2 + fi + systemctl restart avahi-daemon verify From 48cc9c37821a011632c60291cc85cd140f50692e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Jan 2018 13:11:10 +0000 Subject: [PATCH 2/3] batman status --- src/freedombone-mesh-batman | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index 71d0ac2f..b1fbe965 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -54,7 +54,8 @@ function status { if grep -q "bmx6" $MESH_CURRENT_PROTOCOL; then bmx6 -c show=originators - else + fi + if grep -q "bmx7" $MESH_CURRENT_PROTOCOL; then bmx7 -c show=originators fi } From ff13caac42aa852f91d393dba30bbff33cf7f06d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Jan 2018 13:26:15 +0000 Subject: [PATCH 3/3] Missing rootdir --- src/freedombone-image-customise | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 92b6460c..3d31de47 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -688,7 +688,7 @@ EOF chroot "$rootdir" chmod +x /usr/bin/install_olsr2 chroot "$rootdir" /usr/bin/install_olsr2 - if [ ! -f /usr/local/sbin/olsrd2_static ]; then + if [ ! -f $rootdir/usr/local/sbin/olsrd2_static ]; then echo $'Unable to build OLSR2' exit 79835392 fi