Skip to content

Commit

Permalink
Add mkmap.sh-example that shoud be run by cron
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo77 committed Sep 22, 2016
1 parent c33ebf6 commit 404ce72
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ ffmap-backend gathers information on the batman network by invoking :

The output will be written to a directory (`-d output`).

Run `backend.py --help` for a quick overview of all available options.
Copy `mkmap.sh-example` to `mkmap.sh` and adapt to your needs, test `backend.py` for example with:

backend.py -d /path/to/output -a /path/to/aliases.json --vpn ae:7f:58:7d:6c:2a d2:d0:93:63:f7:da

For the script's regular execution add the following to the crontab:
Run `backend.py --help` for a quick overview of all available options.

<pre>
* * * * * backend.py -d /path/to/output -a /path/to/aliases.json --vpn ae:7f:58:7d:6c:2a d2:d0:93:63:f7:da
</pre>
For the script's regular execution add the following file to cron in `/etc/cron.d/ffmap-backend`:

MAILTO=example@your-NOC.org
# Freifunk Map Updates
PATH=/usr/sbin:/usr/bin:/sbin:/bin
* * * * * root nice -n 19 /path/to/mkmap.sh > /dev/null 2>&1
# EOF

# Dependencies

Expand Down
22 changes: 22 additions & 0 deletions mkmap.sh-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
MAXLOAD=2 # don't run when load is equal or bigger than 2.0
FFMAPPATH='/opt/ffmap-backend'
TMPPATH='/tmp/ffmap-backend'
TLD=ffgc

if [ $(pgrep -c $(basename $0)) -gt 2 ]; then
echo $(basename $0) is already running
exit 0
fi

load=`grep -o "^." /proc/loadavg`
if [ "$load" -gt $MAXLOAD ]; then
exit 1
fi

mkdir -p $TMPPATH
cd $FFMAPPATH
cp json/nodes.json $TMPPATH/
python3 $FFMAPPATH/backend.py -d /$TMPPATH/ --aliases $FFMAPPATH/gateway.json -m bat-$TLD:/var/run/alfred.bat-$TLD.sock -p 62 --vpn de:ad:be:ef:ff:01 de:ad:be:ff:ff:02
cp /$TMPPATH/* /$FFMAPPATH/json/

0 comments on commit 404ce72

Please sign in to comment.