Browse Source

add local operation scripts

Helge Jung 6 years ago
parent
commit
6a4c392735
7 changed files with 92 additions and 3 deletions
  1. 5 3
      .gitignore
  2. 8 0
      Readme.md
  3. 16 0
      contrib/alfred-json
  4. 10 0
      contrib/batadv-vis
  5. 15 0
      contrib/batctl
  6. 28 0
      contrib/fetch-current-data.sh
  7. 10 0
      contrib/run-local.sh

+ 5 - 3
.gitignore

@@ -9,7 +9,9 @@
 storage.dat
 storage.dat.autobackup
 
-# dummy scripts + datafiles
-alfred*json
-batadv-vis*
+# dummy datafiles
+/contrib/alfred-*.json
+/contrib/batadv-vis.json
+/contrib/batctl-gwl.txt
+/contrib/batctl-vd.json
 GeoIPISP.dat

+ 8 - 0
Readme.md

@@ -67,3 +67,11 @@ optional arguments:
                         Path where to store data or
                         "redis:[<host>[:<port>[:<password>]]]"
 ```
+
+## Lokaler Betrieb (nur sinnvoll für Entwickler)
+
+Im `contrib/` liegen mehrere Skripte für den lokalen Betrieb:
+
+* **fetch-current-data.sh** lädt aktuelle Rohdaten der Tools alfred-json, batctl und batadv-vis und speichert sie lokal ab.
+* **run-local.sh** startet die BATCAVE und leitet die Aufrufe statt zu den richtigen Tools in Helfer-Skripte im Verzeichnis um.
+

+ 16 - 0
contrib/alfred-json

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# only operate as "alfred-json -z -r NUM"
+[ "$1" != "-z" ] && exit 2
+[ "$2" != "-r" ] && exit 2
+
+num=$3
+if [ -z "$num" ]; then
+	echo "Mimimi"
+	exit 1
+fi
+
+# output requested alfred-NUM.json in script's dir
+fn=`dirname $0`
+fn=`readlink -f "$fn"`
+cat "${fn}/alfred-${num}.json"

+ 10 - 0
contrib/batadv-vis

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# only operate as "batadv-vis -f jsondoc"
+[ "$1" != "-f" ] && exit 2
+[ "$2" != "jsondoc" ] && exit 3
+
+# output JSON in script's dir
+fn=`dirname $0`
+fn=`readlink -f "$fn"`
+cat "${fn}/batadv-vis.json"

+ 15 - 0
contrib/batctl

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# output batctl-vd.json in script's dir
+fn=`dirname $0`
+fn=`readlink -f "$fn"`
+
+# only do something if started with the right set of parameters
+
+if [ "$*" == "vd json -n" ]; then
+	cat "${fn}/batctl-vd.json"
+elif [ "$*" == "gwl" ]; then
+	cat "${fn}/batctl-gwl.txt"
+else
+	exit 1
+fi

+ 28 - 0
contrib/fetch-current-data.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+SERVICES_HOST="${1:-ffpb-services}"
+
+MYDIR="$(dirname $0)"
+MYDIR="$(readlink -f $MYDIR)"
+
+pushd $MYDIR >/dev/null
+
+echo -en "Fetching current BATCAVE data from $SERVICES_HOST ... 0/5"
+
+ssh $SERVICES_HOST alfred-json -z -r 158 > "${MYDIR}/alfred-158.json"
+echo -en "\x08\x08\x081/5"
+
+ssh $SERVICES_HOST alfred-json -z -r 159 > "${MYDIR}/alfred-159.json"
+echo -en "\x08\x08\x082/5"
+
+ssh $SERVICES_HOST batctl gwl > "${MYDIR}/batctl-gwl.txt"
+echo -en "\x08\x08\x083/5"
+
+ssh $SERVICES_HOST batctl vd json -n > "${MYDIR}/batctl-vd.json"
+echo -en "\x08\x08\x084/5"
+
+ssh $SERVICES_HOST batadv-vis -f jsondoc > "${MYDIR}/batadv-vis.json"
+echo -en "\x08\x08\x08done\n"
+
+popd > /dev/null
+

+ 10 - 0
contrib/run-local.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+MYDIR="$(dirname $0)"
+MYDIR="$(readlink -f $MYDIR)"
+
+pushd "${MYDIR}/.." > /dev/null
+
+./batcave.py -A "${MYDIR}/alfred-json" -B "${MYDIR}/batadv-vis" -C "${MYDIR}/batctl" $* #-dv -S redis:
+
+popd > /dev/null