Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mkmap.sh-example that shoud be run by cron #89

Merged
merged 2 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`:

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 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/