1#!/bin/sh /etc/rc.common
2
3START=99
4NAME=sched_updates
5
6## You will see the value 4 instead of 24 for the hours.  The
7## idea is that we only check for updates during 4 hours in the
8## middle of the night.
9## So....
10##     4 * 60 ==  240
11
12
13
14
15##============================================================
16## Get the last bytes of the mac address to use as a 
17## seed for checking the update site.
18get_seed() {
19	awk 'BEGIN {srand(); printf("%d\n", rand()*240)}'
20}
21
22
23##============================================================
24## Build a valid crontab line that we can append to the crontab
25build_cron() {
26	local command=$1
27
28	local seed=$(get_seed)
29
30	local hour=$(expr ${seed} / 60)
31	local minute=$(expr ${seed} % 60)
32
33	echo " ${minute} ${hour}  *   *   *     ${command}"
34}
35
36
37##============================================================
38## Append the new crontab line to the old crontab file.
39add_to_cron() {
40	local tempfile=/tmp/tempfile
41
42	build_cron "$1" > ${tempfile}
43	crontab -l | cat - ${tempfile} | crontab -
44	rm -rf ${tempfile}
45}
46
47##============================================================
48## Remove this script so that it is not run at every boot.
49delete_self() {
50	echo "Deleting /etc/rc.d/S${START}${NAME}"
51	rm -rf /etc/rc.d/S${START}${NAME}
52}
53
54
55boot() {
56## QCA orignal code start
57#	add_to_cron "streamboost auto_upload; streamboost auto_update && streamboost restart"
58#	delete_self
59## QCA orignal code end
60
61## Because DNI has /sbin/cmdsched to manage sched task such as website
62## block, wifi,so we also use /sbin/cmdsched to manage SB auto update 
63	echo "DNI streamboost auto_update"
64}
65