Code

collectd.postinst: Set correct permissions for /var/lib/collectd/rrd/.
[pkg-collectd.git] / debian / collectd.postinst
1 #!/bin/sh
2 # postinst script for collectd
3 #
4 # see: dh_installdeb(1)
6 set -e
8 # summary of how this script can be called:
9 #        * <postinst> `configure' <most-recently-configured-version>
10 #        * <old-postinst> `abort-upgrade' <new version>
11 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 #          <new-version>
13 #        * <postinst> `abort-remove'
14 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 #          <failed-install-package> <version> `removing'
16 #          <conflicting-package> <version>
17 # for details, see http://www.debian.org/doc/debian-policy/ or
18 # the debian-policy package
20 . /usr/share/debconf/confmodule
22 case "$1" in
23     configure)
24         db_get collectd/auto-migrate-3-4
25         if [ "$RET" = "true" ]; then
26             tmpdir=`mktemp -dt collectd.XXXXXXXXXX`
27             hostname=`hostname`
29             if [ -z "$hostname" ]; then hostname="localhost"; fi
31             cp -a /var/lib/collectd/ /var/backups/collectd-"$2"
32             /usr/lib/collectd/utils/migrate-3-4.px \
33                 --hostname="$hostname" --outdir="$tmpdir" | bash
35             rm -rf /var/lib/collectd/
36             mkdir /var/lib/collectd/
37             mv $tmpdir /var/lib/collectd/rrd
38             chmod 0755 /var/lib/collectd/rrd
39         fi
40     ;;
42     abort-upgrade|abort-remove|abort-deconfigure)
43     ;;
45     *)
46         echo "postinst called with unknown argument \`$1'" >&2
47         exit 1
48     ;;
49 esac
51 db_stop
53 # dh_installdeb will replace this with shell code automatically
54 # generated by other debhelper scripts.
56 #DEBHELPER#
58 exit 0