---
 .gitignore                  |    3 +++
 Makefile.am                 |   10 ++++++++++
 daemons/ganeti-cleaner.in   |   39 +++++++++++++++++++++++++++++++++++++++
 doc/examples/ganeti.cron.in |    6 +++++-
 4 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100755 daemons/ganeti-cleaner.in

diff --git a/.gitignore b/.gitignore
index 6a059c0..cff682b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,9 @@
 /*.tar.bz2
 /*.tar.gz
 
+# daemons
+/daemons/ganeti-cleaner
+
 # devel
 /devel/clean-cluster
 /devel/upload
diff --git a/Makefile.am b/Makefile.am
index cda2181..7988c38 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -45,6 +45,7 @@ MAINTAINERCLEANFILES = \
 
 CLEANFILES = \
        autotools/replace_vars.sed \
+       daemons/ganeti-cleaner \
        devel/upload \
        doc/rapi-resources.gen \
        doc/examples/bash_completion \
@@ -139,6 +140,9 @@ dist_sbin_SCRIPTS = \
        scripts/gnt-node \
        scripts/gnt-os
 
+nodist_sbin_SCRIPTS = \
+       daemons/ganeti-cleaner
+
 dist_tools_SCRIPTS = \
        tools/burnin \
        tools/cfgshell \
@@ -151,6 +155,7 @@ EXTRA_DIST = \
        DEVNOTES \
        pylintrc \
        autotools/docbook-wrapper \
+       daemons/ganeti-cleaner.in \
        devel/upload.in \
        $(docrst) \
        $(docdot) \
@@ -243,6 +248,11 @@ doc/examples/%: doc/examples/%.in stamp-directories \
                $(REPLACE_VARS_SED)
        sed -f $(REPLACE_VARS_SED) < $< > $@
 
+daemons/ganeti-cleaner: daemons/ganeti-cleaner.in stamp-directories \
+               $(REPLACE_VARS_SED)
+       sed -f $(REPLACE_VARS_SED) < $< > $@
+       chmod +x $@
+
 doc/%.html: doc/%.rst
        @test -n "$(RST2HTML)" || { echo 'rst2html' not found during configure; 
exit 1; }
        $(RST2HTML) $< $@
diff --git a/daemons/ganeti-cleaner.in b/daemons/ganeti-cleaner.in
new file mode 100755
index 0000000..1815e6d
--- /dev/null
+++ b/daemons/ganeti-cleaner.in
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+
+# Copyright (C) 2009 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+set -e
+
+data_d...@localstatedir@/lib/ganeti
+QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive
+
+# Define how many days archived jobs should be left alone
+REMOVE_AFTER=21
+
+# Exit if machine is not part of a cluster
+[[ -e $DATA_DIR/ssconf_master_node ]] || echo 0
+
+# Exit if queue archive directory doesn't exist
+[[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0
+
+# Remove old jobs
+find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \
+xargs -r0 rm -f
+
+exit 0
diff --git a/doc/examples/ganeti.cron.in b/doc/examples/ganeti.cron.in
index 155411a..6d7d9b0 100644
--- a/doc/examples/ganeti.cron.in
+++ b/doc/examples/ganeti.cron.in
@@ -1,3 +1,7 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
-# restart failed instances
+
+# Restart failed instances (every 5 minutes)
 */5 * * * * root [ -x @SBINDIR@/ganeti-watcher ] && @SBINDIR@/ganeti-watcher
+
+# Clean job archive (at 01:45 AM)
+45 1 * * * root [ -x @SBINDIR@/ganeti-cleaner ] && @SBINDIR@/ganeti-cleaner
-- 
1.6.3.4

Reply via email to