Workout munin configuration upgrade.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Wed, 22 Apr 2009 15:16:07 +0000 (17:16 +0200)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Wed, 22 Apr 2009 15:16:07 +0000 (17:16 +0200)
src/functions.sh

index 5369717..1ac813b 100644 (file)
@@ -1063,6 +1063,31 @@ upgrade_dovecot () {
   fi
 }
 
+# restore munin configs for silent upgrade
+upgrade_munin () {
+  local config backup hostname domain
+
+  for pkg_name in munin munin-node; do
+     pkg $pkg_name lt '1.2.6-10~lenny1' || continue
+
+     config=/etc/munin/$pkg_name.conf
+     backup=$config.$backup_ext
+     if [ -f $config -a ! -f $backup ]; then
+        hostname=$(hostname)
+        domain=$(hostname --domain)
+
+        cp -av $config $backup
+        check_and_sed "$hostname.$domain" \
+          "s/$hostname.$domain/localhost.localdomain/g" $config
+     fi
+     pkgadd $pkg_name
+  done
+
+  # force localhost -> hostname replacement in config files
+  pkgadd munin-cn
+  dpkg-reconfigure munin-cn
+}
+
 # fix /etc/dpkg/dpkg.cfg
 comment_force_overwrite () {
   if [ -f /etc/dpkg/dpkg.cfg ]; then