2 # postinst script for bind9-cn
4 # see: dh_installdeb(1)
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>
13 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 # <failed-install-package> <version> `removing'
15 # <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
21 configure|reconfigure)
31 . /usr/share/carnet-tools/functions.sh
33 # check if monitrc is an empty template
35 if [ -e /etc/monit/monitrc ]; then
36 lines=$(grep -v '^#' /etc/monit/monitrc | wc -l)
37 if [ $lines -lt 2 ]; then
39 mv -f /etc/monit/monitrc /etc/monit/monitrc.dpkg-old
44 if [ $installfile -eq 1 ]; then
45 echo "CN: Installing default monitrc in /etc/monit/monitrc"
46 cp -a /usr/share/monit-cn/monitrc /etc/monit/monitrc
47 chmod u=rw,go= /etc/monit/monitrc
50 # generate monit.d files
53 # disable monit startup
54 cp_check_and_sed '^startup=1/#startup=1/g' /etc/default/monit \
57 # install as inittab service
58 if ! grep -q '/usr/sbin/monit' /etc/inittab; then
59 if [ -x "/etc/init.d/monit" ]; then
60 update-rc.d -f monit remove >/dev/null 2>&1
61 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
62 invoke-rc.d monit stop || true
64 /etc/init.d/monit stop || true
67 echo "CN: Installing monit service in /etc/inittab"
69 cp /etc/inittab /etc/inittab.$$
70 cp-update monit-cn /etc/inittab.$$ <<EOF
71 mo:2345:respawn:/usr/sbin/monit -Ic /etc/monit/monitrc
72 m0:06:wait:/usr/sbin/monit -Ic /etc/monit/monitrc stop myprocess
74 cp_mv /etc/inittab.$$ /etc/inittab
77 # reload init, since we have new configuration
78 echo "CN: Starting monit service, please check /var/log/daemon.log"
81 # dh_installdeb will replace this with shell code automatically
82 # generated by other debhelper scripts.