added --full option to vacuumdb
[myplc.git] / plc.d / crond
index 67cfb3f..c4275c8 100755 (executable)
@@ -7,11 +7,18 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
+# $Id$
 #
 
 # Source function library and configuration
 . /etc/plc.d/functions
+. /etc/planetlab/plc_config
+
+# Be verbose
+set -x
+
+# Export so that we do not have to specify -p to psql invocations
+export PGPORT=$PLC_DB_PORT
 
 case "$1" in
     start)
@@ -23,25 +30,41 @@ case "$1" in
        else
            MAILTO=
        fi
+
        cat >/etc/cron.d/plc.cron <<EOF
 SHELL=/bin/bash
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 MAILTO=$MAILTO
 HOME=/
-
+#
 # minute hour day-of-month month day-of-week user command
-*/5 * * * * root gen-slices-xml-05.py
-*/15 * * * * root gen-sites-xml.py
-*/15 * * * * root gen-static-content.py
 EOF
 
-        # Run them once at startup
-       gen-slices-xml-05.py
-       check
-       gen-sites-xml.py
-       check
-       gen-static-content.py
-       check
+        # Run all jobs once at startup
+
+       if [ "$PLC_WWW_ENABLED" = "1" ] ; then
+           echo "00 * * * * wget -O - -q http://localhost/cron.php" >>/etc/cron.d/plc.cron
+           wget -O - -q http://localhost/cron.php
+           check
+       fi
+
+       if [ "$PLC_DNS_ENABLED" = "1" ] ; then
+           echo "*/15 * * * * root dns-config" >>/etc/cron.d/plc.cron
+           dns-config
+           check
+       fi
+
+       if [ "$PLC_DB_ENABLED" = "1" ] ; then
+           echo "5 5 * * * root vacuumdb -U postgres --all --analyze --quiet --full" >>/etc/cron.d/plc.cron
+           vacuumdb -U postgres --all --analyze --quiet
+           check
+       fi
+
+       if [ "$PLC_WWW_ENABLED" = "1" ] ; then
+         echo "*/15 * * * * root clean-empty-dirs.py /var/tmp/bootmedium" >> /etc/cron.d/plc.cron
+         clean-empty-dirs.py /var/tmp/bootmedium
+         check
+       fi
 
        plc_daemon crond
        check