Browse Source

Mesh script can also run on a 'server' (i.e. a dedicated peer)

Bob Mottram 9 years ago
parent
commit
b7c8141ae5
1 changed files with 28 additions and 10 deletions
  1. 28
    10
      src/freedombone-mesh

+ 28
- 10
src/freedombone-mesh View File

@@ -40,6 +40,12 @@ TOX_PORT=33445
40 40
 TOXCORE_REPO='git://github.com/irungentoo/toxcore.git'
41 41
 TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
42 42
 
43
+# client or server installations sounds odd for a mesh, but this
44
+# indicates whether this is a dedicated mesh peer ("yes") or
45
+# a 'client' such as a laptop or desktop machine with
46
+# the freedombone-client script installed
47
+SERVER_INSTALLATION="no"
48
+
43 49
 function install_toxcore {
44 50
     if [ -f /etc/tox-bootstrapd.conf ]; then
45 51
         return
@@ -207,8 +213,14 @@ function run_tox {
207 213
     fi
208 214
 }
209 215
 
210
-if [ ! -f /usr/bin/batman ]; then
211
-    freedombone-client
216
+if [ -f /var/lib/batman ]; then
217
+    SERVER_INSTALLATION="yes"
218
+fi
219
+
220
+if [[ $SERVER_INSTALLATION == "no" ]]; then
221
+    if [ ! -f /usr/bin/batman ]; then
222
+        freedombone-client
223
+    fi
212 224
 fi
213 225
 
214 226
 # alternative toxic paths
@@ -219,12 +231,14 @@ if [ -f /usr/local/share/toxic/DHTnodes ]; then
219 231
     DHTNODES=/usr/local/share/toxic/DHTnodes
220 232
 fi
221 233
 
222
-if [ ! -f /tmp/meshtype ]; then
223
-    install_toxcore
224
-    install_toxid
225
-    sudo batman start
226
-    if [ ! "$?" = "0" ]; then
227
-        exit 2
234
+if [[ $SERVER_INSTALLATION == "no" ]]; then
235
+    if [ ! -f /tmp/meshtype ]; then
236
+        install_toxcore
237
+        install_toxid
238
+        sudo batman start
239
+        if [ ! "$?" = "0" ]; then
240
+            exit 2
241
+        fi
228 242
     fi
229 243
 fi
230 244
 
@@ -294,7 +308,9 @@ if [ ! -f $IRSSI_PATH ]; then
294 308
             exit 0
295 309
         fi
296 310
         echo 'You need irssi/mumble/toxic installed on your system'
297
-        sudo batman stop
311
+        if [[ $SERVER_INSTALLATION == "no" ]]; then
312
+            sudo batman stop
313
+        fi
298 314
         exit 4
299 315
     fi
300 316
 fi
@@ -307,7 +323,9 @@ if [ ! -f $MUMBLE_PATH ]; then
307 323
             exit 0
308 324
         fi
309 325
         echo 'You need irssi/mumble/toxic installed on your system'
310
-        sudo batman stop
326
+        if [[ $SERVER_INSTALLATION == "no" ]]; then
327
+            sudo batman stop
328
+        fi
311 329
         exit 4
312 330
     fi
313 331
 fi