1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#! /bin/sh
set -e
prevver="$2"
initperms() {
chown munin:adm /var/log/munin
chmod 755 /var/log/munin
chown root:munin /etc/munin/plugin-conf.d
chmod 750 /etc/munin/plugin-conf.d
}
# create symlinks below /etc/munin/plugins/ for all plugins reporting "yes" via "autoconf"
init_plugins() {
TMPFILE=$(mktemp /tmp/munin-node.configure.XXXXXXXXXX)
TMPFILE_STDERR=$(mktemp /tmp/munin-node.configure.err.XXXXXXXXXX)
MUNIN_NODE_CONF_LOG="/var/log/munin/munin-node-configure.log"
if [ -n "$prevver" ]; then
MUNIN_NODE_CMD="munin-node-configure --shell --newer '${prevver%-*}'"
echo -n "Initializing new plugins.."
else
MUNIN_NODE_CMD="munin-node-configure --shell"
echo -n "Initializing plugins.."
fi
# munin-node-conf returns 1 in case of partial plugin autoconf
# errors. We need to ignore these errors as even one plugin
# can fail the entire process. See Debian bug #539886 for details.
$MUNIN_NODE_CMD 2>"$TMPFILE_STDERR" >"$TMPFILE" || true
# log the details
{
echo "$(date '+%b %d %T') - Starting $MUNIN_NODE_CMD"
cat "$TMPFILE"
if [ -s "$TMPFILE_STDERR" ]; then
echo "The following errors were reported by $MUNIN_NODE_CMD"
cat "$TMPFILE_STDERR"
fi
} >>"$MUNIN_NODE_CONF_LOG"
# create the symlinks for new plugins
sh <"$TMPFILE"
echo "done."
rm -f "$TMPFILE" "$TMPFILE_STDERR"
}
case "$1" in
configure)
if [ -z "$2" ]; then
initperms
fi
init_plugins
;;
triggered)
if [ "$2" = "perl-major-upgrade" ]; then
invoke-rc.d munin-node restart
fi
;;
esac
#DEBHELPER#
|