[debian-edu-commits] [Git][debian-edu/upstream/sitesummary][master] 3 commits: Place munin configuration in include file

Mike Gabriel (@sunweaver) gitlab at salsa.debian.org
Mon Aug 7 15:37:49 BST 2023



Mike Gabriel pushed to branch master at Debian Edu / upstream / sitesummary


Commits:
3ad87771 by Guido Berhoerster at 2023-08-07T14:37:31+00:00
Place munin configuration in include file

Ensure a munin.conf file exists so that include files will be included.  Ensure
MUNINDIR is always set.  Drop configuration settings which were set to upstream
default values. Ensure Remove support for ancient munin versions.
Closes: #762652.

- - - - -
d0da2fc7 by Guido Berhoerster at 2023-08-07T14:37:31+00:00
Add systemd timer unit for sitesummary-client

This replaces the init script for systemd-based installations.
Closes: #1039369

- - - - -
48af53e6 by Guido Berhoerster at 2023-08-07T14:37:31+00:00
Add systemd timer for sitesummary maintenance

- - - - -


11 changed files:

- README
- debian/rules
- + debian/sitesummary-client.sitesummary-client.service
- + debian/sitesummary-client.sitesummary-client.timer
- + debian/sitesummary-maintenance
- debian/sitesummary.cron.daily
- debian/sitesummary.install
- debian/sitesummary.postrm
- + debian/sitesummary.sitesummary.service
- + debian/sitesummary.sitesummary.timer
- sitesummary-update-munin


Changes:

=====================================
README
=====================================
@@ -11,9 +11,8 @@ Sitesummary can be used to generate Munin configuration to collect
 statistics from all sitesummary clients with the Munin packages
 installed.  To enable it, install the munin package and make sure
 /etc/sitesummary/collector.cfg include 'MUNINDIR=/etc/munin' to get
-sitesummary to replace the default munin configuration with the
-generated one.  Running these commands as root normally does the
-trick.
+sitesummary to add an include file to the default munin configuration.
+Running these commands as root normally does the trick:
 
   aptitude install munin munin-node
   echo MUNINDIR=/etc/munin >> /etc/sitesummary/collector.cfg


=====================================
debian/rules
=====================================
@@ -7,3 +7,7 @@
 # No need to submit information when the package is installed
 override_dh_installinit:
 	dh_installinit --no-start
+
+override_dh_installsystemd:
+	dh_installsystemd --no-start --name sitesummary
+	dh_installsystemd --no-start --name sitesummary-client


=====================================
debian/sitesummary-client.sitesummary-client.service
=====================================
@@ -0,0 +1,10 @@
+[Unit]
+Description=Report status to sitesummary server after boot
+After=network-online.target
+
+[Service]
+Type=oneshot
+EnvironmentFile=-/etc/environment
+EnvironmentFile=-/etc/default/sitesummary-client
+Nice=10
+ExecStart=/usr/sbin/sitesummary-client


=====================================
debian/sitesummary-client.sitesummary-client.timer
=====================================
@@ -0,0 +1,8 @@
+[Unit]
+Description=Timer for sitesummary reporting after boot
+
+[Timer]
+OnBootSec=5min
+
+[Install]
+WantedBy=timers.target


=====================================
debian/sitesummary-maintenance
=====================================
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Author: Petter Reinholdtsen
+
+set -e
+
+daylimit=120
+makewebreport=/usr/sbin/sitesummary-makewebreport
+nodes=/usr/sbin/sitesummary-nodes
+
+[ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg
+
+# Exit imediately if the package is removed but nor purged
+if [ ! -x $nodes ] ; then
+    exit 0
+fi
+
+# The storage area is not configurable, because too many scripts have
+# it hardcoded
+entriesdir=/var/lib/sitesummary/entries
+
+remove_old_entries() {
+    find $entriesdir/. -mindepth 1 -maxdepth 1 -type d \
+	-daystart -mtime +$daylimit \
+	-exec /usr/lib/sitesummary/expire-entry '{}' \;
+}
+
+[ -d $entriesdir ] && remove_old_entries
+
+if [ -x /usr/sbin/sitesummary-update-nagios ] ; then
+    /usr/sbin/sitesummary-update-nagios
+fi
+
+if [ -x /usr/sbin/sitesummary-update-munin ] ; then
+    /usr/sbin/sitesummary-update-munin
+fi
+
+# Update the web report once a day
+[ -x $makewebreport ] && nice $makewebreport


=====================================
debian/sitesummary.cron.daily
=====================================
@@ -1,39 +1,8 @@
 #!/bin/sh
-#
-# Author: Petter Reinholdtsen
 
-set -e
-
-daylimit=120
-makewebreport=/usr/sbin/sitesummary-makewebreport
-nodes=/usr/sbin/sitesummary-nodes
-
-[ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg
-
-# Exit imediately if the package is removed but nor purged
-if [ ! -x $nodes ] ; then
-    exit 0
+# Do not run on systemd-based installations or if the package is removed but
+# not purged
+if [ -x /usr/lib/sitesummary/sitesummary-maintenance ] && \
+    [ ! -d /run/systemd/system ]; then
+    /usr/lib/sitesummary/sitesummary-maintenance
 fi
-
-# The storage area is not configurable, because too many scripts have
-# it hardcoded
-entriesdir=/var/lib/sitesummary/entries
-
-remove_old_entries() {
-    find $entriesdir/. -mindepth 1 -maxdepth 1 -type d \
-	-daystart -mtime +$daylimit \
-	-exec /usr/lib/sitesummary/expire-entry '{}' \;
-}
-
-[ -d $entriesdir ] && remove_old_entries
-
-if [ -x /usr/sbin/sitesummary-update-nagios ] ; then
-    /usr/sbin/sitesummary-update-nagios
-fi
-
-if [ -x /usr/sbin/sitesummary-update-munin ] ; then
-    /usr/sbin/sitesummary-update-munin
-fi
-
-# Update the web report once a day
-[ -x $makewebreport ] && nice $makewebreport


=====================================
debian/sitesummary.install
=====================================
@@ -8,3 +8,4 @@ usr/sbin/sitesummary-nodes
 usr/sbin/sitesummary-update-munin
 usr/sbin/sitesummary-update-nagios
 usr/share/munin/plugins
+debian/sitesummary-maintenance usr/lib/sitesummary/sitesummary-maintenance


=====================================
debian/sitesummary.postrm
=====================================
@@ -4,8 +4,8 @@ set -e
 
 if [ "$1" = "purge" ] ; then
     cd /var/lib/sitesummary
-    rm -rf entries tmpstorage www
-    rm -f munin.conf munin.conf.pre munin.conf.post
+    rm -rf entries tmpstorage www munin-conf.d
+    rm -f munin.conf
     rm -f nagios-generated.cfg
 fi
 


=====================================
debian/sitesummary.sitesummary.service
=====================================
@@ -0,0 +1,6 @@
+[Unit]
+Description=Regular sitesummary maintenance
+
+[Service]
+Type=oneshot
+ExecStart=/usr/lib/sitesummary/sitesummary-maintenance


=====================================
debian/sitesummary.sitesummary.timer
=====================================
@@ -0,0 +1,9 @@
+[Unit]
+Description=Timer for regular sitesummary maintenance
+
+[Timer]
+OnCalendar=daily
+Persistent=true
+
+[Install]
+WantedBy=timers.target


=====================================
sitesummary-update-munin
=====================================
@@ -4,76 +4,49 @@
 
 set -e
 
+umask 022
+
 nodes=/usr/sbin/sitesummary-nodes
 muninopts=""
 
-# Modify this in collector.cfg to /etc/munin/ to automatically replace
-# the default munin configuration.
-MUNINDIR=/var/lib/sitesummary
-
-if [ -d /var/cache/munin/www ] ; then
-    # Used since munin version 1.4.0-1
-    muninhtmldir="/var/cache/munin/www"
-else
-    muninhtmldir="/var/www/munin"
-fi
-# Based on of active config from munin version 1.2.5-1
-munindbdir=/var/lib/munin
-muninlogdir=/var/log/munin
-muninrundir=/var/run/munin
-munintmpldir=/etc/munin/templates
-
+# Set MUNINDIR in collector.cfg to /etc/munin/ to automatically add hosts to
+# the default munin configuration via include files.
 [ -f /etc/sitesummary/collector.cfg ] && . /etc/sitesummary/collector.cfg
 
+# Default to /var/lib/sitesummary and canonicalize path.
+MUNINDIR="$(realpath -mqs "${MUNINDIR:-/var/lib/sitesummary}")"
+
 # The storage area is not configurable, because too many scripts have
 # it hardcoded
 entriesdir=/var/lib/sitesummary/entries
 
 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
-	    cat <<EOF
-# Munin server configuration generated from cron using sitesummary
-# data by $0
-# Do not edit, it will be overwritten. 
-# Edit $MUNINDIR/munin.conf.pre and
-# $MUNINDIR/munin.conf.post instead.
+    # Add -c /var/lib/sitesummary/munin.conf to the calls to the munin scripts,
+    # or change MUNINDIR as described above.
 
-dbdir	$munindbdir
-htmldir	$muninhtmldir
-logdir	$muninlogdir
-rundir	$muninrundir
-tmpldir	$munintmpldir
+    mkdir -p "${MUNINDIR}/munin-conf.d"
+    chmod a+rx "${MUNINDIR}/munin-conf.d"
 
-EOF
-
-            # Munin supports the includedir statement since Squeeze
-            muninver=$(dpkg -l munin|grep munin|awk '{print $3}')
-            if dpkg --compare-versions "1.4.5" le "$muninver" ; then
-	        cat <<EOF
+    if [ ! -f "${MUNINDIR}/munin.conf" ]; then
+        cat > "${MUNINDIR}/munin.conf" <<EOF
 # (Exactly one) directory to include all files from.
 #
-includedir /etc/munin/munin-conf.d
-
+includedir "${MUNINDIR}/munin-conf.d"
 EOF
-            fi
-	fi
-
-	$nodes -m $muninopts
+        chown root:root "${MUNINDIR}/munin.conf"
+    fi
 
-	[ -f $MUNINDIR/munin.conf.post ] && cat $MUNINDIR/munin.conf.post
+    (
+        cat <<EOF
+# Munin server configuration generated from cron using sitesummary
+# data by $0
+# Do not edit, it will be overwritten.
+EOF
 
-        # Make sure the subshell return true to trigger the mv below.
-	true
-    ) > $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
+        $nodes -m $muninopts
+    ) >"${MUNINDIR}/munin-conf.d/sitesummary.conf" &&
+        chown root:root "${MUNINDIR}/munin-conf.d/sitesummary.conf"
 }
 
 # Only enable if munin and sitesummary is installed.



View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/compare/5028c11ca79d76a8f1462068fb5cf78ae3f0a5d2...48af53e6a8def65b85ad0ef4afd8c4ab17154eb5

-- 
View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/compare/5028c11ca79d76a8f1462068fb5cf78ae3f0a5d2...48af53e6a8def65b85ad0ef4afd8c4ab17154eb5
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20230807/e153a37c/attachment-0001.htm>


More information about the debian-edu-commits mailing list