From b7c8141ae50349987df811b5f5f32bfcddb35706 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 27 Aug 2015 20:54:06 +0100 Subject: [PATCH] Mesh script can also run on a 'server' (i.e. a dedicated peer) --- src/freedombone-mesh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/freedombone-mesh b/src/freedombone-mesh index 5a52d666..7530a7a1 100755 --- a/src/freedombone-mesh +++ b/src/freedombone-mesh @@ -40,6 +40,12 @@ TOX_PORT=33445 TOXCORE_REPO='git://github.com/irungentoo/toxcore.git' TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt +# client or server installations sounds odd for a mesh, but this +# indicates whether this is a dedicated mesh peer ("yes") or +# a 'client' such as a laptop or desktop machine with +# the freedombone-client script installed +SERVER_INSTALLATION="no" + function install_toxcore { if [ -f /etc/tox-bootstrapd.conf ]; then return @@ -207,8 +213,14 @@ function run_tox { fi } -if [ ! -f /usr/bin/batman ]; then - freedombone-client +if [ -f /var/lib/batman ]; then + SERVER_INSTALLATION="yes" +fi + +if [[ $SERVER_INSTALLATION == "no" ]]; then + if [ ! -f /usr/bin/batman ]; then + freedombone-client + fi fi # alternative toxic paths @@ -219,12 +231,14 @@ if [ -f /usr/local/share/toxic/DHTnodes ]; then DHTNODES=/usr/local/share/toxic/DHTnodes fi -if [ ! -f /tmp/meshtype ]; then - install_toxcore - install_toxid - sudo batman start - if [ ! "$?" = "0" ]; then - exit 2 +if [[ $SERVER_INSTALLATION == "no" ]]; then + if [ ! -f /tmp/meshtype ]; then + install_toxcore + install_toxid + sudo batman start + if [ ! "$?" = "0" ]; then + exit 2 + fi fi fi @@ -294,7 +308,9 @@ if [ ! -f $IRSSI_PATH ]; then exit 0 fi echo 'You need irssi/mumble/toxic installed on your system' - sudo batman stop + if [[ $SERVER_INSTALLATION == "no" ]]; then + sudo batman stop + fi exit 4 fi fi @@ -307,7 +323,9 @@ if [ ! -f $MUMBLE_PATH ]; then exit 0 fi echo 'You need irssi/mumble/toxic installed on your system' - sudo batman stop + if [[ $SERVER_INSTALLATION == "no" ]]; then + sudo batman stop + fi exit 4 fi fi