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