check_mysql_health: 2.1.8.4 with fixed --negate
[omd.git] / debian / postinst.in
blob882f5b5592d96d90047a94f366f8673fa9e6cf9d
1 #!/bin/sh
2 # postinst script for omd
4 # see: dh_installdeb(1)
6 set -e
8 NAGIOS_PLUGIN_PATH="/omd/versions/###OMD_VERSION###/lib/nagios/plugins"
9 SUID_PLUGINS="check_icmp check_dhcp"
10 PROGRAM_PATH="/omd/versions/###OMD_VERSION###/bin"
11 SUID_PROGRAMS="mkeventd_open514"
12 APACHE_OMD_CONF="/etc/apache2/conf.d/zzz_omd.conf"
14 # Source debconf library.
15 . /usr/share/debconf/confmodule
17 # summary of how this script can be called:
18 # * <postinst> `configure' <most-recently-configured-version>
19 # * <old-postinst> `abort-upgrade' <new version>
20 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
21 # <new-version>
22 # * <postinst> `abort-remove'
23 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
24 # <failed-install-package> <version> `removing'
25 # <conflicting-package> <version>
26 # for details, see http://www.debian.org/doc/debian-policy/ or
27 # the debian-policy package
29 setperm() {
30 local user="$1"
31 local group="$2"
32 local mode="$3"
33 local file="$4"
34 shift 4
35 # only do something when no setting exists
36 if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
37 chown "$user":"$group" "$file"
38 chmod "$mode" "$file"
42 case "$1" in
43 configure)
44 ln -sfn /opt/omd /omd
45 update-alternatives --install /omd/versions/default \
46 omd /omd/versions/###OMD_VERSION### ###OMD_SERIAL### \
47 --slave /usr/bin/omd omd.bin /omd/versions/###OMD_VERSION###/bin/omd \
48 --slave /usr/share/man/man8/omd.8.gz omd.man8 \
49 /omd/versions/###OMD_VERSION###/share/man/man8/omd.8.gz
51 # -- looking for group nagios, create it, if not exist
52 if ! getent group omd > /dev/null ; then
53 echo 'Adding system group omd' 1>&2
54 addgroup --system --force-badname omd > /dev/null
57 db_get omd/nagios-plugins-suid || true
58 if [ "$RET" = "true" ]; then
59 PLUGPERM="4754"
60 else
61 PLUGPERM="0755"
63 for PLUGIN in $SUID_PLUGINS; do
64 setperm root omd $PLUGPERM $NAGIOS_PLUGIN_PATH/$PLUGIN
65 done
66 for PROGRAM in $SUID_PROGRAMS; do
67 setperm root omd $PLUGPERM $PROGRAM_PATH/$PROGRAM
68 done
70 db_stop
71 # -- create apache config include if not exist
72 if test -d /etc/apache2/conf-available; then
73 # On e.g. ubuntu 13.10 conf.d is not loaded anymore, use conf-available
74 APACHE_OMD_CONF="/etc/apache2/conf-available/zzz_omd.conf"
77 if ! test -e $APACHE_OMD_CONF; then
78 echo "Include /omd/apache/*.conf" > $APACHE_OMD_CONF
79 # avoid apache error message including /omd/apache if no site exist
80 touch "/omd/apache/empty.conf"
82 # -- enable conf include, when available
83 if test -d /etc/apache2/conf-available; then
84 a2enconf zzz_omd
88 # -- enable apache modules
89 if ! test -e /etc/apache2/mods-enabled/proxy_http.load; then
90 a2enmod proxy_http # also enables dependend modules
92 if ! test -e /etc/apache2/mods-enabled/rewrite.load; then
93 a2enmod rewrite
96 # -- default for init
97 DEFAULT=/etc/default/omd
98 if ! test -e $DEFAULT ; then
99 echo "AUTOSTART=1" > $DEFAULT
103 abort-upgrade|abort-remove|abort-deconfigure)
104 exit 0
108 echo "postinst called with unknown argument \`$1'" >&2
109 exit 1
111 esac
113 # dh_installdeb will replace this with shell code automatically
114 # generated by other debhelper scripts.
116 #DEBHELPER#
118 exit 0