From 87d5c2ac57388ea358a0a53cc26d6a0159757485 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 31 Aug 2015 13:01:09 +0100 Subject: [PATCH] Install a web server on mesh clients for the zeronet tracker --- src/freedombone | 3 ++- src/freedombone-meshweb | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/freedombone b/src/freedombone index 825cfa0d..d48ffc2d 100755 --- a/src/freedombone +++ b/src/freedombone @@ -6043,6 +6043,7 @@ function configure_firewall_for_zeronet { iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT + iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT save_firewall_settings echo 'configure_firewall_for_zeronet' >> $COMPLETION_FILE @@ -7391,7 +7392,7 @@ function import_email { } function install_web_server { - if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then + if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then return fi if grep -Fxq "install_web_server" $COMPLETION_FILE; then diff --git a/src/freedombone-meshweb b/src/freedombone-meshweb index 5d247c8b..7911eaef 100755 --- a/src/freedombone-meshweb +++ b/src/freedombone-meshweb @@ -13,6 +13,24 @@ ZERONET_DIR=~/zeronet ZERONET_URL=http://127.0.0.1:43110 TRACKER_PORT=6969 +function install_web_server { + if [ -d /etc/nginx ]; then + return + fi + + sudo apt-get -y remove --purge apache2 + if [ -d /etc/apache2 ]; then + sudo rm -rf /etc/apache2 + fi + # install nginx + sudo apt-get -y install nginx + + if [ ! -d /etc/nginx ]; then + echo 'Unable to install web server' + exit 51 + fi +} + function install_zeronet { if [ -d $ZERONET_DIR ]; then return @@ -42,6 +60,7 @@ fi if [[ $SERVER_INSTALLATION == "no" ]]; then if [ ! -f /tmp/meshtype ]; then + install_web_server install_zeronet sudo batman start if [ ! "$?" = "0" ]; then @@ -78,9 +97,9 @@ cd $ZERONET_DIR existing_bttrack=$(ps aux | grep bttrack | wc -l) if [ $existing_bttrack -lt "2" ]; then - if [ ! -d ~/.bttrack ]; then - mkdir ~/.bttrack - fi + if [ ! -d ~/.bttrack ]; then + mkdir ~/.bttrack + fi bttrack --port ${TRACKER_PORT} --dfile ~/.bttrack/dstate --logfile ~/.bttrack/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0 & fi