67cfb3f4d2d8e735de26271713a6c5417f6c1558
[myplc.git] / plc.d / crond
1 #!/bin/bash
2 #
3 # priority: 900
4 #
5 # Configure cron jobs
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10 # $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15
16 case "$1" in
17     start)
18         MESSAGE=$"Starting crond"
19         dialog "$MESSAGE"
20
21         if [ "$PLC_MAIL_ENABLED" = "1" ] ; then
22             MAILTO=$PLC_MAIL_SUPPORT_ADDRESS
23         else
24             MAILTO=
25         fi
26         cat >/etc/cron.d/plc.cron <<EOF
27 SHELL=/bin/bash
28 PATH=/sbin:/bin:/usr/sbin:/usr/bin
29 MAILTO=$MAILTO
30 HOME=/
31
32 # minute hour day-of-month month day-of-week user command
33 */5 * * * * root gen-slices-xml-05.py
34 */15 * * * * root gen-sites-xml.py
35 */15 * * * * root gen-static-content.py
36 EOF
37
38         # Run them once at startup
39         gen-slices-xml-05.py
40         check
41         gen-sites-xml.py
42         check
43         gen-static-content.py
44         check
45
46         plc_daemon crond
47         check
48
49         result "$MESSAGE"       
50         ;;
51
52     stop)
53         MESSAGE=$"Stopping crond"
54         dialog "$MESSAGE"
55
56         killproc plc_crond
57         check
58
59         result "$MESSAGE"       
60         ;;
61 esac
62
63 exit $ERRORS