34f371c795e97c7a30e095f855817b75b38de3ee
[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: crond,v 1.4 2006/05/26 19:57:30 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
16
17 # Be verbose
18 set -x
19
20 case "$1" in
21     start)
22         MESSAGE=$"Starting crond"
23         dialog "$MESSAGE"
24
25         if [ "$PLC_MAIL_ENABLED" = "1" ] ; then
26             MAILTO=$PLC_MAIL_SUPPORT_ADDRESS
27         else
28             MAILTO=
29         fi
30         cat >/etc/cron.d/plc.cron <<EOF
31 SHELL=/bin/bash
32 PATH=/sbin:/bin:/usr/sbin:/usr/bin
33 MAILTO=$MAILTO
34 HOME=/
35
36 # minute hour day-of-month month day-of-week user command
37 */5 * * * * root gen-slices-xml-05.py
38 */15 * * * * root gen-sites-xml.py
39 */15 * * * * root gen-static-content.py
40 */15 * * * * root dns-config
41 5 5 * * * root vacuumdb -U postgres --all --analyze --quiet
42 EOF
43
44         # Run them once at startup
45         gen-slices-xml-05.py
46         check
47         gen-sites-xml.py
48         check
49         gen-static-content.py
50         check
51         dns-config
52         check
53         vacuumdb -U postgres --all --analyze --quiet
54         check
55
56         plc_daemon crond
57         check
58
59         result "$MESSAGE"       
60         ;;
61
62     stop)
63         MESSAGE=$"Stopping crond"
64         dialog "$MESSAGE"
65
66         killproc plc_crond
67         check
68
69         result "$MESSAGE"       
70         ;;
71 esac
72
73 exit $ERRORS