random.sh: random timing for netmon communication

Signed-off-by: Tim Niemeyer <tim.niemeyer@mastersword.de>
Reviewed-by: Steffen Pankratz <kratz00@gmx.de>
This commit is contained in:
Tim Niemeyer 2015-11-29 12:35:15 +01:00 committed by Steffen Pankratz
parent b37f9a36a8
commit d97a8eac87
2 changed files with 18 additions and 1 deletions

View File

@ -1,2 +1,3 @@
*/5 * * * * sh /etc/fastdstart.sh; sh /etc/nodewatcher.sh; sh /etc/configurator.sh; /etc/syncHostname.sh
*/5 * * * * sleep $(/etc/random.sh 0 29); sh /etc/fastdstart.sh; sh /etc/nodewatcher.sh; sleep $(/etc/random 0 209); sh /etc/configurator.sh
0/30 * * * * sleep $(/etc/random.sh 0 1790); /etc/syncHostname.sh
*/1 * * * * /usr/sbin/batctl gw off; sleep 1; /usr/sbin/batctl gw client

View File

@ -0,0 +1,16 @@
#!/bin/sh
# Freifunk Franken Random Number Script
# Tim Niemeyer
# 29.11.2015
# License GPLv2
FROM=${1:-0}
UNTIL=${2:-100}
diff=$(( UNTIL - FROM ))
numbers=$(( $(echo $diff | wc -c) -1 ))
rand=$(</dev/urandom tr -dc 0-9 | head -c $numbers | sed -e 's/^0*//g')
echo $(( (rand % diff) + FROM ))