File: munin-node.postinst

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (69 lines) | stat: -rw-r--r-- 2,196 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
#! /bin/sh

set -e

prevver="$2"

add_munin_system_user() {
	if ! getent passwd munin >/dev/null; then
		adduser --group --system --no-create-home --home /var/lib/munin munin;
	fi	
}

fixperms() {
        dpkg-statoverride --list /var/log/munin >/dev/null || \
		dpkg-statoverride --update --add munin adm 0750 /var/log/munin
        dpkg-statoverride --list /var/run/munin >/dev/null || \
		dpkg-statoverride --update --add munin root 0755 /var/run/munin
        dpkg-statoverride --list /var/lib/munin >/dev/null || \
		dpkg-statoverride --update --add munin munin 0755 /var/lib/munin
        dpkg-statoverride --list /var/lib/munin/plugin-state >/dev/null || \
		dpkg-statoverride --update --add munin munin 0775 /var/lib/munin/plugin-state
}

init_plugins() {
	if [ "$prevver" ]; then
		echo -n "Initializing new plugins.."
		munin-node-configure --shell --newer "${prevver%-*}" | sh
	else
		echo -n "Initializing plugins.."
		munin-node-configure --shell | sh
	fi
	echo "done."
}

move_startup_links() {
	# only do so if we're upgrading
	dpkg --compare-versions "$prevver" "<=" "1.2.0-1" || return 0
	# and certainly not if the user has fiddled around with them - this
	# is sacred user configuration
	links=$(echo /etc/rc0.d/???munin-node /etc/rc1.d/???munin-node /etc/rc2.d/???munin-node /etc/rc3.d/???munin-node /etc/rc4.d/???munin-node /etc/rc5.d/???munin-node /etc/rc6.d/???munin-node)
	[ x"$links" = x"/etc/rc0.d/K20munin-node /etc/rc1.d/K20munin-node /etc/rc2.d/S20munin-node /etc/rc3.d/S20munin-node /etc/rc4.d/S20munin-node /etc/rc5.d/S20munin-node /etc/rc6.d/K20munin-node" ] || return 0
	for link in $links; do
		[ x"$(readlink "$link")" = x"../init.d/munin-node" ] || return 0
	done
	# ok, should be safe now
	mv /etc/rc2.d/S20munin-node /etc/rc2.d/S98munin-node
	mv /etc/rc3.d/S20munin-node /etc/rc3.d/S98munin-node
	mv /etc/rc4.d/S20munin-node /etc/rc4.d/S98munin-node
	mv /etc/rc5.d/S20munin-node /etc/rc5.d/S98munin-node
}
		

case "$1" in
	configure)
		add_munin_system_user
		fixperms
		init_plugins
		move_startup_links
		;;
	abort-upgrade|abort-deconfigure|abort-remove)
		:
		;;
	*)
		echo "Called with unknown argument $1, bailing out."
		exit 1
		;;
esac

#DEBHELPER#