commit 8f3fca99d1f735786a242463c9b2af71b2833877
Author: Francois POIROTTE <francois.poirotte@c-s.fr>
Date:   Mon Jun 9 15:15:17 2014 +0200

    [#1224] Acquittement et purge automatique.
    
    Ajoute une tâche cron permettant d'acquitter et de purger
    automatiquement les alertes de VigiBoard en fonction de certains
    critères.
    
    Refs; #1224.
    
    Change-Id: Ifefb70a5766d0702f1c27a33a642b8931c98655a
    Reviewed-on: https://vigilo-dev.si.c-s.fr/review/1428
    Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
    Reviewed-by: Thomas BURGUIERE <thomas.burguiere@c-s.fr>

diff --git a/Makefile b/Makefile
index ae6697e..2283cf9 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,8 @@ SUBST_FILES := \
 	deployment/logrotate.conf \
 	deployment/settings.ini   \
 	deployment/vigiboard.conf \
-	deployment/vigiboard.wsgi
+	deployment/vigiboard.wsgi \
+	pkg/vigilo-vigiboard.sh
 
 all: build
 build: $(SUBST_FILES)
@@ -20,6 +21,10 @@ deployment/%: deployment/%.in
 	    -e 's,@NAGIOS_BIN@,$(NAGIOS_BIN),g' \
 	    -e 's,@LOCALSTATEDIR@,$(LOCALSTATEDIR),g' $^ > $@
 
+pkg/vigilo-vigiboard.sh: pkg/vigilo-vigiboard.sh.in
+	sed -e 's,@INITCONFDIR@,$(INITCONFDIR),g' \
+		-e 's,@BINDIR@,$(BINDIR),g' $^ > $@
+
 install: build install_python install_data
 install_pkg: build install_python_pkg install_data
 
@@ -30,6 +35,9 @@ install_python_pkg: $(PYTHON) $(SUBST_FILES)
 		$(SETUP_PY_OPTS) --root=$(DESTDIR) --record=INSTALLED_FILES
 
 install_data: $(SUBST_FILES)
+	# Configuration de la tâche cron.
+	install -p -m 644 -D pkg/initconf $(DESTDIR)$(INITCONFDIR)/$(PKGNAME)
+	echo $(INITCONFDIR)/$(PKGNAME) >> INSTALLED_FILES
 	# Permissions de la conf
 	chmod a+rX -R $(DESTDIR)$(SYSCONFDIR)/vigilo/$(NAME)
 	[ `id -u` -ne 0 ] || chgrp $(HTTPD_USER) $(DESTDIR)$(SYSCONFDIR)/vigilo/$(NAME)/*.ini
diff --git a/pkg/initconf b/pkg/initconf
new file mode 100644
index 0000000..e4b7343
--- /dev/null
+++ b/pkg/initconf
@@ -0,0 +1,17 @@
+# Les alertes de plus de ACK jours seront automatiquement acquittées.
+# Utiliser la valeur -1 pour désactiver l'acquittement automatique.
+ACK=-1
+
+# Options pour contrôler l'acquittement automatique.
+# Consulter `vigiboard-close --help` pour plus d'information.
+ACK_OPTIONS="-uk"
+
+# Les alertes de plus de PURGE jours seront automatiquement purgées.
+# Utiliser la valeur -1 pour désactiver la purge automatique.
+# ATTENTION: la purge des alertes entraîne leur effacement définitif
+#            de la base de données Vigilo.
+PURGE=-1
+
+# Options pour contrôler la purge automatique.
+# Consulter `vigiboard-purge --help` pour plus d'information.
+PURGE_OPTIONS=""
diff --git a/pkg/vigiboard.mandriva.spec b/pkg/vigiboard.mandriva.spec
index 01977ad..27a0763 100644
--- a/pkg/vigiboard.mandriva.spec
+++ b/pkg/vigiboard.mandriva.spec
@@ -117,9 +117,12 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.py
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.wsgi
 %config(noreplace) %attr(640,root,apache) %{_sysconfdir}/vigilo/%{module}/*.ini
-%config(noreplace) /etc/httpd/conf/webapps.d/%{name}.conf
+%config(noreplace) %{_sysconfdir}/httpd/conf/webapps.d/%{name}.conf
 %dir %{_localstatedir}/log/vigilo/
 %attr(750,apache,apache) %{_localstatedir}/log/vigilo/%{module}
-%config(noreplace) /etc/logrotate.d/%{name}
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
 %attr(750,apache,apache) %{_localstatedir}/cache/vigilo/sessions
 %{python_sitelib}/*
+%attr(755,root,root) %{_sysconfdir}/cron.daily/*
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
+
diff --git a/pkg/vigiboard.redhat.spec b/pkg/vigiboard.redhat.spec
index c697870..7b83234 100644
--- a/pkg/vigiboard.redhat.spec
+++ b/pkg/vigiboard.redhat.spec
@@ -66,9 +66,11 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.py
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.wsgi
 %config(noreplace) %attr(640,root,apache) %{_sysconfdir}/vigilo/%{module}/*.ini
-%config(noreplace) /etc/httpd/conf.d/%{name}.conf
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
 %dir %{_localstatedir}/log/vigilo/
 %attr(750,apache,apache) %{_localstatedir}/log/vigilo/%{module}
-%config(noreplace) /etc/logrotate.d/%{name}
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
 %attr(750,apache,apache) %{_localstatedir}/cache/vigilo/sessions
 %{python_sitelib}/*
+%attr(755,root,root) %{_sysconfdir}/cron.daily/*
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
diff --git a/pkg/vigiboard.rhel6.spec b/pkg/vigiboard.rhel6.spec
index df66504..f5927cd 100644
--- a/pkg/vigiboard.rhel6.spec
+++ b/pkg/vigiboard.rhel6.spec
@@ -59,9 +59,11 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.py
 %config(noreplace) %{_sysconfdir}/vigilo/%{module}/*.wsgi
 %config(noreplace) %attr(640,root,apache) %{_sysconfdir}/vigilo/%{module}/*.ini
-%config(noreplace) /etc/httpd/conf.d/%{name}.conf
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
 %dir %{_localstatedir}/log/vigilo/
 %attr(750,apache,apache) %{_localstatedir}/log/vigilo/%{module}
-%config(noreplace) /etc/logrotate.d/%{name}
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
 %attr(750,apache,apache) %{_localstatedir}/cache/vigilo/sessions
 %{python_sitelib}/*
+%attr(755,root,root) %{_sysconfdir}/cron.daily/*
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
diff --git a/pkg/vigilo-vigiboard.sh.in b/pkg/vigilo-vigiboard.sh.in
new file mode 100755
index 0000000..8210920
--- /dev/null
+++ b/pkg/vigilo-vigiboard.sh.in
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+ACK=-1
+ACK_OPTIONS="-uk"
+PURGE=-1
+PURGE_OPTIONS=""
+
+if [ -f '@INITCONFDIR@/vigilo-vigiboard' ]; then
+    . '@INITCONFDIR@/vigilo-vigiboard'
+fi
+
+if [ "$ACK" -gt -1 ]; then
+    @BINDIR@/vigiboard-close $ACK_OPTIONS -d $ACK
+fi
+
+if [ "$PURGE" -gt -1 ]; then
+    @BINDIR@/vigiboard-purge $PURGE_OPTIONS -d $PURGE
+fi
diff --git a/setup.py b/setup.py
index 6643914..2a527c0 100755
--- a/setup.py
+++ b/setup.py
@@ -101,5 +101,9 @@ setup(
             'deployment/settings.ini',
             'deployment/who.ini',
         ]),
+        (
+            os.path.join(sysconfdir, 'cron.daily'),
+            [os.path.join('pkg', 'vigilo-vigiboard.sh')]
+        ),
     ],
 )
