#!/bin/sh # Antonio Ávila for Fon Technology (GPL) crontab_file="/etc/crontabs/root" ntp_file="/etc/config/ntpservers" #Flush previous ntp servers... cat /etc/crontabs/root | grep -v ntp > /etc/crontabs/root randline=$(expr `head -c1 /dev/urandom | hexdump -d | sed 's/\ //g' | sed 's/^0*//' | head -n1` % `wc -l $ntp_file | sed 's/^\ [ \t]*//' | cut -d" " -f1`) ntpserver=$(head -n$randline $ntp_file | tail -n1) case "$1" in "stop") cat $crontab_file | grep -v "ntp" > $crontab_file crontab -l echo stop return ;; *) ;; esac randminute=$(expr `head -c2 /dev/urandom | hexdump -d | sed 's/\ //g' | sed 's/^0*//' | head -n1` % 60) randhour=$(expr `head -c2 /dev/urandom | hexdump -d | sed 's/\ //g' | sed 's/^0*//' | head -n1` % 24) echo "$randminute $randhour * * * ntpclient -s -h $ntpserver" >> $crontab_file ntpclient -s -h $ntpserver & crontab -l