Code

Added possibility to automatically migrate RRD files from v3 to v4.
authorSebastian Harl <sh@tokkee.org>
Sun, 29 Apr 2007 13:57:03 +0000 (15:57 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 2 May 2007 18:00:53 +0000 (18:00 +0000)
A debconf question has been added to ask the user weather he wishes to let
collectd try to automatically migrate old RRD files using migrate-3-4.px. A
backup of /var/lib/collectd/ will be created in this case.

debian/collectd.config [new file with mode: 0755]
debian/collectd.postinst [new file with mode: 0755]
debian/collectd.templates [new file with mode: 0644]
debian/control
debian/rules

diff --git a/debian/collectd.config b/debian/collectd.config
new file mode 100755 (executable)
index 0000000..09a4703
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+# config script for collectd
+#
+# see: dh_installdebconf(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <preconfigure> `configure' <installed-version>
+#        * <postinst> `configure' <old-version>
+#        * <reconfigure> `reconfigure' <installed-version>
+
+. /usr/share/debconf/confmodule
+
+case "$1" in
+    configure)
+        db_set collectd/auto-migrate-3-4 false
+
+        if dpkg --compare-versions "$2" lt "4.0.0~"; then
+            db_input high collectd/auto-migrate-3-4 || true
+            db_go || true
+        fi
+    ;;
+
+    reconfigure)
+    ;;
+
+    *)
+        echo "config called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+db_stop
+
+exit 0
+
+
diff --git a/debian/collectd.postinst b/debian/collectd.postinst
new file mode 100755 (executable)
index 0000000..d34dee4
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# postinst script for collectd
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+. /usr/share/debconf/confmodule
+
+case "$1" in
+    configure)
+        db_get collectd/auto-migrate-3-4
+        if [ "$RET" = "true" ]; then
+            cp -a /var/lib/collectd/ /var/backups/collectd-"$2"
+            /usr/lib/collectd/utils/migrate-3-4.px | bash
+        fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+db_stop
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/debian/collectd.templates b/debian/collectd.templates
new file mode 100644 (file)
index 0000000..e9b8021
--- /dev/null
@@ -0,0 +1,14 @@
+Template: collectd/auto-migrate-3-4
+Type: boolean
+Default: false
+Description: Automatically try to migrate your RRD files?
+ The layout of the RRD files created by collectd has changed significantly
+ since version 3.x. In order to keep your old data you have to migrate it.
+ This can be done by using /usr/lib/collectd/utils/migrate-3-4.px. This step
+ can be done automatically. In this case a backup of /var/lib/collectd/ is
+ made in /var/backups/.
+ .
+ See /usr/share/doc/collectd/README.Debian for details.
+ .
+ This script is still experimental. Do not expect it to work in all cases.
+
index 423f3faa218c25031ecd183524c56cd26b24a877..0bf2179abf800f22e102ca4c32d76f168b06bd65 100644 (file)
@@ -8,7 +8,7 @@ Standards-Version: 3.7.2
 
 Package: collectd
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Suggests: collectd-apache, collectd-mysql, collectd-sensors, collectd-dev,
  collectd-ping, collectd-dns, collectd-perl,librrds-perl, hddtemp, mbmon
 Provides: collectd-hddtemp
index bfe05920116795fe0aa73b5271edc254c6f3f27b..9d7a0fb930c20b87aceebb04c2fada2cb3a44c47 100755 (executable)
@@ -112,6 +112,7 @@ binary-arch: build install-arch
        dh_installdocs -A -a debian/README.Debian AUTHORS README TODO
        dh_installexamples -a contrib/collectd2html.pl contrib/collection.cgi \
                contrib/PerlLib/ contrib/SpamAssassin/ contrib/iptables/
+       dh_installdebconf -a
        dh_installinit -a -- defaults 95
        dh_installman -a src/collectd.1 src/collectd.conf.5
        dh_link -a