Skip to content

Commit

Permalink
Add mkmap.sh-example that shoud be run by cron (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo77 authored Oct 30, 2017
1 parent 6041249 commit ff304b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +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.

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

[email protected]
# 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 1 ]; 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 ff304b1

Please sign in to comment.