#!/bin/sh /etc/rc.common START=99 BIN="/usr/sbin/bmx7-auto-bw-test" CRONTAB="/etc/crontabs/root" SAVE="/tmp/bmx7-internet-bw.log" start() { echo "Ensuring bmx7-auto-bw-test is run by cron" if ! ( grep -q "$BIN" "$CRONTAB" 2>/dev/null ) ; then # run twice and random sleep for better entropy local rnd=$(awk 'BEGIN{srand();print int(rand()*3)}') sleep $rnd rnd=$(awk 'BEGIN{srand();print int(rand()*60)}') echo "$rnd */6 * * * SAVE=$SAVE $BIN" >> "$CRONTAB" /etc/init.d/cron enable /etc/init.d/cron restart fi } stop() { echo "Removing bmx7-auto-bw-test from crontab" sed "\|$BIN|d" -i "$CRONTAB" /etc/init.d/cron restart } reload() { $BIN }