2 # postinst script for icinga2-classicui
6 . /usr/share/debconf/confmodule
9 en="/etc/icinga2/classicui"
11 # location of the default apache configuration for icinga
12 apacheconf=$en/apache2.conf
13 # location of the default htpasswd authentication file.
14 htpw=$en/htpasswd.users
22 # only do something when no setting exists
23 if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
24 chown "$user":"$group" "$file"
37 enable_features_for_classic() {
38 if is_fresh_install $@; then
39 echo "enabling icinga2 features for classicui"
41 for feature in compatlog statusdata command; do
42 icinga2-enable-feature $feature
45 echo "reloading icinga2"
46 [ -x $(which invoke-rc.d) ] && invoke-rc.d icinga2 reload
48 # handle new default features here in the future
53 enable_features_for_classic $@
55 echo "enabling Apache2 config..."
56 COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
58 # NEW method for Apache >= 2.4
59 if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
60 . /usr/share/apache2/apache2-maintscript-helper
62 apache2_invoke enconf icinga2-classicui
64 # OLD methods for Apache < 2.4
65 elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
66 # create symlink if not existing
67 [ -f /etc/apache2/conf.d/icinga2-classicui.conf ] || ln -vs ../../icinga2/classicui/apache2.conf /etc/apache2/conf.d/icinga2-classicui.conf
70 [ -x $(which invoke-rc.d) ] && invoke-rc.d apache2 reload
76 db_get icinga2-classicui/adminpassword
79 test -f "$htpw" || touch "$htpw"
80 setperm root www-data 0640 "$htpw"
82 # we reset the password every run, so if it exists we're running
83 # after being specifically given a password and can unconditionally set it.
84 # XXX there's no way of setting the pw w/out giving it on the cmdline? wtf?
85 if [ -n "$admpass" ]; then
86 #unfortunatly that method only works with 2.4
87 if htpasswd 2>&1 | grep -q ' -i'; then
88 echo "$admpass" | htpasswd -i "$htpw" icingaadmin
90 htpasswd -b "$htpw" icingaadmin "$admpass"
94 # everything went well, so now let's reset the password
95 db_set icinga2-classicui/adminpassword ""
96 db_set icinga2-classicui/adminpassword-repeat ""
97 # ... done with debconf here
102 abort-upgrade|abort-remove|abort-deconfigure)
106 echo "postinst called with unknown argument \`$1'" >&2
113 echo "Icinga 2 was unable to start due to configuration errors.";
114 echo "Please fix them and manually restart the icinga2 daemon using";
115 echo " ´service icinga2 start´";