GUI CSS: Refactored wato styles to nested structure meeting sasslint requirements...
[check_mk.git] / omd / debian / postinst.in
blobc1e6b4e87e16eb2ba9d5474cb79d68b3ca1e2d7e
1 #!/bin/sh
2 # postinst script for omd
4 # see: dh_installdeb(1)
6 set -e
8 PLUGIN_PATH="/omd/versions/###OMD_VERSION###/lib"
9 SUID_PLUGINS="nagios/plugins/check_icmp nagios/plugins/check_dhcp cmc/icmpsender cmc/icmpreceiver"
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 if [ ! -d /etc/bash_completion.d ]; then
46 mkdir /etc/bash_completion.d
48 update-alternatives --install /omd/versions/default \
49 omd /omd/versions/###OMD_VERSION### ###OMD_SERIAL### \
50 --slave /usr/bin/omd omd.bin /omd/versions/###OMD_VERSION###/bin/omd \
51 --slave /etc/bash_completion.d/omd omd.bash_completion /omd/versions/###OMD_VERSION###/lib/omd/bash_completion \
52 --slave /usr/share/man/man8/omd.8.gz omd.man8 \
53 /omd/versions/###OMD_VERSION###/share/man/man8/omd.8.gz
55 # -- looking for group nagios, create it, if not exist
56 if ! getent group omd > /dev/null ; then
57 echo 'Adding system group omd' 1>&2
58 addgroup --system --force-badname omd > /dev/null
61 db_get omd/nagios-plugins-suid || true
62 if [ "$RET" = "true" ]; then
63 PLUGPERM="4754"
64 else
65 PLUGPERM="0755"
67 for PLUGIN in $SUID_PLUGINS; do
68 if [ -f $PLUGIN_PATH/$PLUGIN ]; then
69 setperm root omd $PLUGPERM $PLUGIN_PATH/$PLUGIN
71 done
72 for PROGRAM in $SUID_PROGRAMS; do
73 if [ -f $PROGRAM_PATH/$PROGRAM ]; then
74 setperm root omd $PLUGPERM $PROGRAM_PATH/$PROGRAM
76 done
78 db_stop
79 # -- create apache config include if not exist
80 if test -d /etc/apache2/conf-available; then
81 # On e.g. ubuntu 13.10 conf.d is not loaded anymore, use conf-available
82 APACHE_OMD_CONF="/etc/apache2/conf-available/zzz_omd.conf"
85 if ! test -e $APACHE_OMD_CONF; then
86 echo "Include /omd/apache/*.conf" > $APACHE_OMD_CONF
87 # avoid apache error message including /omd/apache if no site exist
88 touch "/omd/apache/empty.conf"
90 # -- enable conf include, when available
91 ! test -x /usr/sbin/a2enconf || a2enconf zzz_omd
94 # -- enable apache modules
95 if ! test -e /etc/apache2/mods-enabled/proxy_http.load; then
96 a2enmod proxy_http # also enables dependend modules
98 if ! test -e /etc/apache2/mods-enabled/rewrite.load; then
99 a2enmod rewrite
102 echo "New default version is ###OMD_VERSION###."
103 update-alternatives --set omd /omd/versions/###OMD_VERSION###
105 DEFAULT=/etc/default/omd
107 # Detect whether or not manage startup through systemd or SysV
108 if test -d /usr/lib/systemd && dpkg -S /sbin/init 2>/dev/null | grep ^systemd >/dev/null; then
109 echo "Installing systemd service: omd.init"
111 echo "Disabling startup through SysV (/etc/init.d/*) scripts"
112 echo "AUTOSTART=0" > $DEFAULT
114 echo "Activating startup during system boot"
115 cp /omd/versions/default/share/omd/omd.service /etc/systemd/system/omd.service
116 systemctl daemon-reload
117 systemctl enable omd
119 else
120 # -- default for init
121 if ! test -e $DEFAULT ; then
122 echo "Activating startup during system boot"
123 echo "AUTOSTART=1" > $DEFAULT
129 abort-upgrade|abort-remove|abort-deconfigure)
130 exit 0
134 echo "postinst called with unknown argument \`$1'" >&2
135 exit 1
137 esac
139 # dh_installdeb will replace this with shell code automatically
140 # generated by other debhelper scripts.
142 #DEBHELPER#
144 exit 0