From ff304b1a5255143d48ff717af388f3dfe83c74c6 Mon Sep 17 00:00:00 2001 From: Ruben Barkow Date: Mon, 30 Oct 2017 16:27:50 +0100 Subject: [PATCH] Add mkmap.sh-example that shoud be run by cron (#89) --- README.md | 14 +++++++++++--- mkmap.sh-example | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 mkmap.sh-example diff --git a/README.md b/README.md index f8b74c3..37e4a88 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/mkmap.sh-example b/mkmap.sh-example new file mode 100644 index 0000000..f9ff1da --- /dev/null +++ b/mkmap.sh-example @@ -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/ +