clamav PID introduced again
[monit-cn.git] / debian / postinst
index 29a05cd..2e2af2f 100755 (executable)
@@ -1,39 +1,17 @@
 #!/bin/sh
-# postinst script for monit-cn
-#
-# 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>
-#        * <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
-#
+[ "$1" = "configure" ] || exit 0
+[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
 
-case "$1" in
-    configure|reconfigure)
-      # continue below
-    ;;
-
-    *)
-        exit 0
-    ;;
-esac
-
-# import CN-functions
+# Load CARNET Tools
 . /usr/share/carnet-tools/functions.sh
 
 # check if monitrc is ours
 installfile=1
 if [ -e /etc/monit/monitrc ]; then
-    if ! grep -q "CARNet package monit-cn" /etc/monit/monitrc; then
+    if ! grep -q "CARNET package monit-cn" /etc/monit/monitrc; then
         installfile=1
         mv -f /etc/monit/monitrc /etc/monit/monitrc.dpkg-old
     else
@@ -55,6 +33,15 @@ if grep -q '@localhost' /etc/monit/monitrc; then
         /etc/monit/monitrc || true
 fi
 
+# sed bacula-fd.conf with proper hostname
+if grep -q '127.0.0.1' /usr/share/monit-cn/bacula-fd.conf; then
+    cp_check_and_sed '127.0.0.1' \
+        "s/127.0.0.1/$CARNET_HOSTNAME.$CARNET_DOMAINNAME/" \
+        /usr/share/monit-cn/bacula-fd.conf || true
+fi
+
+# you can modify others in a loop, maybe?
+
 # migrate to "but not on { instance }" alerting style
 cp_check_and_sed '^set alert [^[:space:]]*@[^[:space:]]* ' \
     's/^set alert \([^[:space:]]*@[^[:space:]]*\) .*$/set alert \1 but not on { instance }/g' \
@@ -76,7 +63,7 @@ cp_check_and_sed '^START[[:space:]]*=[[:space:]]*no' \
     's/^START[[:space:]]*=.*/START=yes/g' /etc/default/monit || true
 
 # remove us from systemv monit script
-if grep -q 'CARNet package monit-cn' /etc/init.d/monit; then
+if grep -q 'CARNET package monit-cn' /etc/init.d/monit; then
   echo "CN: Removing monit workaround from /etc/init.d/monit -- systemd is in use"
   cp-update -r monit-cn /etc/init.d/monit
   chmod +x /etc/init.d/monit