Check */*.rpm for signing.
[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$
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
34         cat >/etc/cron.d/plc.cron <<EOF
35 SHELL=/bin/bash
36 PATH=/sbin:/bin:/usr/sbin:/usr/bin
37 MAILTO=$MAILTO
38 HOME=/
39 #
40 # minute hour day-of-month month day-of-week user command
41 EOF
42
43         # Run all jobs once at startup
44
45 #       if [ "$PLC_BOOT_ENABLED" = "1" ] ; then
46 #           echo "*/5 * * * * root gen-slices-xml-05.py" >>/etc/cron.d/plc.cron
47 #           gen-slices-xml-05.py
48 #           check
49         fi
50
51         if [ "$PLC_WWW_ENABLED" = "1" ] ; then
52 #           echo "*/15 * * * * root gen-static-content.py" >>/etc/cron.d/plc.cron
53 #           echo "*/15 * * * * root gen-sites-xml.py" >>/etc/cron.d/plc.cron
54             echo "00 * * * * wget -O - -q http://localhost/cron.php" >>/etc/cron.d/plc.cron
55 #           gen-static-content.py
56 #           check
57 #           gen-sites-xml.py
58 #           check
59             wget -O - -q http://localhost/cron.php
60             check
61         fi
62
63         if [ "$PLC_DNS_ENABLED" = "1" ] ; then
64             echo "*/15 * * * * root dns-config" >>/etc/cron.d/plc.cron
65             dns-config
66             check
67         fi
68
69         if [ "$PLC_DB_ENABLED" = "1" ] ; then
70             echo "5 5 * * * root vacuumdb -U postgres --all --analyze --quiet" >>/etc/cron.d/plc.cron
71             vacuumdb -U postgres --all --analyze --quiet
72             check
73         fi
74
75         if [ "$PLC_WWW_ENABLED" = "1" ] ; then
76           echo "*/15 * * * * root clean-empty-dirs.py /var/tmp/bootmedium" >> /etc/cron.d/plc.cron
77           clean-empty-dirs.py /var/tmp/bootmedium
78           check
79         fi
80
81         plc_daemon crond
82         check
83
84         result "$MESSAGE"       
85         ;;
86
87     stop)
88         MESSAGE=$"Stopping crond"
89         dialog "$MESSAGE"
90
91         killproc plc_crond
92         check
93
94         result "$MESSAGE"       
95         ;;
96 esac
97
98 exit $ERRORS