aboutsummaryrefslogtreecommitdiff
path: root/assets/09cron
blob: 42c3386322cc4258c7ffbe504fe6d8cae98ea069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/system/bin/sh
: '
 ============ Copyright (C) 2010 Jared Rummler (JRummy16) ============
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 =====================================================================
' 

#############
# FUNCTIONS #
#############

symlink_system_bin() {
	# crond has "/bin/sh" hardcoded
	if busybox [ ! -h /bin ]
	then
		mount -o remount,rw rootfs /
		busybox ln -s /system/bin /bin
		mount -o remount,ro rootfs /
	fi
}

export_timezone() {
	# set timezone (if you're not between -0500 and -0800 you get PST)
	# todo - support other timezones
	timezone=`date +%z`
	if busybox [ $timezone = "-0800" ]; then
	  TZ=PST8PDT
	elif busybox [ $timezone = "-0700" ]; then
	  TZ=MST7MDT
	elif busybox [ $timezone = "-0600" ]; then
	  TZ=CST6CDT
	elif busybox [ $timezone = "-0500" ]; then
	  TZ=EST5EDT
	else
		TZ=PST8PDT
	fi
	export TZ
}

set_crontab() {
	# use /data/cron, call the crontab file "root"
	if busybox [ -e /data/cron/root ]
	then
		mkdir -p /data/cron
		cat > /data/cron/root << EOF
01 * * * * busybox run-parts /system/etc/cron/cron.hourly
02 4 * * * busybox run-parts /system/etc/cron/cron.daily
22 4 * * 0 busybox run-parts /system/etc/cron/cron.weekly
EOF
	fi
	busybox crond -c /data/cron
}

########
# MAIN #
########

symlink_system_bin
export_timezone
set_crontab