64fa7afe7940e79f20a5740a547c107cdf577768
[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.5 2006/06/23 20:29:22 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 # Export so that we do not have to specify -p to psql invocations
21 export PGPORT=$PLC_DB_PORT
22
23 case "$1" in
24     start)
25         MESSAGE=$"Starting crond"
26         dialog "$MESSAGE"
27
28         if [ "$PLC_MAIL_ENABLED" = "1" ] ; then
29             MAILTO=$PLC_MAIL_SUPPORT_ADDRESS
30         else
31             MAILTO=
32         fi
33         cat >/etc/cron.d/plc.cron <<EOF
34 SHELL=/bin/bash
35 PATH=/sbin:/bin:/usr/sbin:/usr/bin
36 MAILTO=$MAILTO
37 HOME=/
38
39 # minute hour day-of-month month day-of-week user command
40 */5 * * * * root gen-slices-xml-05.py
41 */15 * * * * root gen-sites-xml.py
42 */15 * * * * root gen-static-content.py
43 */15 * * * * root dns-config
44 5 5 * * * root vacuumdb -U postgres --all --analyze --quiet
45 EOF
46
47         # Run them once at startup
48         gen-slices-xml-05.py
49         check
50         gen-sites-xml.py
51         check
52         gen-static-content.py
53         check
54         dns-config
55         check
56         vacuumdb -U postgres --all --analyze --quiet
57         check
58
59         plc_daemon crond
60         check
61
62         result "$MESSAGE"       
63         ;;
64
65     stop)
66         MESSAGE=$"Stopping crond"
67         dialog "$MESSAGE"
68
69         killproc plc_crond
70         check
71
72         result "$MESSAGE"       
73         ;;
74 esac
75
76 exit $ERRORS