From 23fbecf15adeb1af173c6ee38e2280dae8f17de0 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Thu, 31 May 2007 11:32:19 +0000 Subject: [ Petter Reinholdtsen ] * Add code in the server cronjob to generate a replacement munin.conf, and make it possible to activate it in munin by setting MUNINDIR=/etc/munin/ in collector.cfg. * Add preseedable hidden boolean debconf question sitesummary/replace-munin-config to make it possible to enable this feature at install time. * Update the postinst script to make sure the install time code is only executed during configure. --- debian/changelog | 14 +++++++++++ debian/sitesummary.cron.daily | 51 ++++++++++++++++++++++++++++++++++++- debian/sitesummary.postinst | 58 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 110 insertions(+), 13 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 90efe28..2317cba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +sitesummary (0.0.26) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Add code in the server cronjob to generate a replacement + munin.conf, and make it possible to activate it in munin by + setting MUNINDIR=/etc/munin/ in collector.cfg. + * Add preseedable hidden boolean debconf question + sitesummary/replace-munin-config to make it possible to enable + this feature at install time. + * Update the postinst script to make sure the install time code is + only executed during configure. + + -- Petter Reinholdtsen Mon, 31 May 2007 13:13:55 +0200 + sitesummary (0.0.25) unstable; urgency=low [ Petter Reinholdtsen ] diff --git a/debian/sitesummary.cron.daily b/debian/sitesummary.cron.daily index bb8dbc7..e3ed7cc 100755 --- a/debian/sitesummary.cron.daily +++ b/debian/sitesummary.cron.daily @@ -2,12 +2,19 @@ # # Author: Petter Reinholdtsen +set -e + daylimit=120 makewebreport=/usr/sbin/sitesummary-makewebreport +# Modify this in collector.cfg to /etc/munin/ to automatically replace +# the default munin configuration. +MUNINDIR=/var/lib/sitesummary + [ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg -# The storage area is not configurable, because too many scripts have it hardcoded +# The storage area is not configurable, because too many scripts have +# it hardcoded entriesdir=/var/lib/sitesummary/entries remove_old_entries() { @@ -16,6 +23,48 @@ remove_old_entries() { xargs -0 -r rm -rf } +generate_munin_config() { + # Generate munin config. Edit /etc/cron.d/munin to enable it. + # Add -c /var/lib/sitesummary/sitesummary-munin.conf to the calls + # to the munin scripts, or change MUNINDIR above. + ( + if [ -f $MUNINDIR/munin.conf.pre ] ; then + cat $MUNINDIR/munin.conf.pre + else + # Copy of active config from munin version 1.2.5-1 + cat < $MUNINDIR/munin.conf.new && \ + chown root:root $MUNINDIR/munin.conf.new && \ + chmod a+r $MUNINDIR/munin.conf.new && \ + mv $MUNINDIR/munin.conf.new $MUNINDIR/munin.conf +} + +# Only enable if munin is installed. +if [ -f /etc/munin/munin.conf ] ; then + generate_munin_config +fi + [ -d $entriesdir ] && remove_old_entries # Update the web report once a day diff --git a/debian/sitesummary.postinst b/debian/sitesummary.postinst index ac8e084..e720788 100644 --- a/debian/sitesummary.postinst +++ b/debian/sitesummary.postinst @@ -2,19 +2,53 @@ set -e -# Adjust to the new config location, in /etc/apache2/conf.d/sitesummary -if [ -f /etc/apache2/sites-available/sitesummary ] ; then - if [ -f /etc/apache2/sites-enabled//sitesummary ] && - [ -x /usr/sbin/a2dissite ] ; then - a2dissite sitesummary - fi - rm /etc/apache2/sites-available/sitesummary -fi +# Source debconf library. +. /usr/share/debconf/confmodule -# Make sure the cgi script can write to the storage area -chown www-data /var/lib/sitesummary/tmpstorage /var/lib/sitesummary/entries +case "$1" in + configure) -# Generate the web page at install time -[ -f /var/lib/sitesummary/www/index.html ] || /etc/cron.daily/sitesummary + # Adjust to the new config location, in + # /etc/apache2/conf.d/sitesummary + if [ -f /etc/apache2/sites-available/sitesummary ] ; then + if [ -f /etc/apache2/sites-enabled//sitesummary ] && + [ -x /usr/sbin/a2dissite ] ; then + a2dissite sitesummary + fi + rm /etc/apache2/sites-available/sitesummary + fi + + # Make sure the cgi script can write to the storage area + chown www-data /var/lib/sitesummary/tmpstorage \ + /var/lib/sitesummary/entries + + # If the config file is missing, check debconf to see if the + # munin configuration feature should be enabled. This hidden + # debconf question allow preseeding during installation. + config=/etc/sitesummary/collector.cfg + if [ ! -f $config ] ; then + db_get sitesummary/replace-munin-config + if [ true = "$RET" ] ; then + echo 'MUNINDIR=/etc/munin' > $config + fi + fi + + # Generate the web page at install time + [ -f /var/lib/sitesummary/www/index.html ] || \ + /etc/cron.daily/sitesummary + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac #DEBHELPER# + +exit 0 -- cgit v1.2.3