2 # postinst script for omd
4 # see: dh_installdeb(1)
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>
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
35 # only do something when no setting exists
36 if ! dpkg-statoverride
--list "$file" >/dev
/null
2>&1; then
37 chown
"$user":"$group" "$file"
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
/man
8/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
67 for PLUGIN
in $SUID_PLUGINS; do
68 if [ -f $PLUGIN_PATH/$PLUGIN ]; then
69 setperm root omd
$PLUGPERM $PLUGIN_PATH/$PLUGIN
72 for PROGRAM
in $SUID_PROGRAMS; do
73 if [ -f $PROGRAM_PATH/$PROGRAM ]; then
74 setperm root omd
$PLUGPERM $PROGRAM_PATH/$PROGRAM
79 # -- create apache config include if not exist
80 if test -d /etc
/apache
2/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
/apache
2/mods-enabled
/proxy_http.load
; then
96 a2enmod proxy_http
# also enables dependend modules
98 if ! test -e /etc
/apache
2/mods-enabled
/rewrite.load
; then
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
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
)
134 echo "postinst called with unknown argument \`$1'" >&2
139 # dh_installdeb will replace this with shell code automatically
140 # generated by other debhelper scripts.