This file is indexed.

postinst is in icinga-common 1.13.3-2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash

set -e

# some shorthands for sanity
en="/etc/icinga"
enc="/etc/icinga/objects"
usn="/usr/share/icinga"

. /usr/share/debconf/confmodule

conffile="/etc/icinga/icinga.cfg"

if [ -n "$ICINGADEBUG" ]; then
  echo "now debugging $0 $@"
  set -x
fi

setperm() {
    local user="$1"
    local group="$2"
    local mode="$3"
    local file="$4"
    shift 4
    # only do something when no setting exists
    if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
      chown "$user":"$group" "$file"
      chmod "$mode" "$file"
    fi
}

case "$1" in
  configure)
    if ! getent passwd nagios > /dev/null ; then
      echo 'Adding system-user for nagios' 1>&2
      adduser --system --group --home /var/lib/nagios \
              --disabled-login --force-badname nagios > /dev/null
    fi

	# explicitly set permissions on some files that are dependent
	# on the uid/gid of the nagios user, which is dynamically created.
        [ -f "$en/resource.cfg" ] && setperm root nagios 0640 $en/resource.cfg
        setperm nagios adm 2751 /var/log/icinga
        setperm nagios adm 2755 /var/log/icinga/archives
	setperm nagios nagios 0750 /var/lib/icinga/spool
	setperm nagios nagios 0755 /var/lib/icinga
	setperm nagios nagios 0750 /var/lib/icinga/spool/checkresults
        setperm nagios www-data 02750 /var/cache/icinga
        setperm nagios www-data 0700 /var/lib/icinga/rw

	db_get icinga/check_external_commands
	check_external_commands="$RET" # boolean

	db_stop

	# translate debconf boolean into icinga option
	# (this is better than using a select in debconf with Choices-C,
	# otherwise all translators would need to translate 'yes' and 'no').

	case $check_external_commands in
		true)
			check_external_commands=1
			;;

		false)
			check_external_commands=0
			;;
	esac

	# If the admin deleted or commented some variables but then set
	# them via debconf, (re-)add them to the config file.

	test -z "$check_external_commands" || \
	grep -Eq '^ *check_external_commands=' "$conffile" || \
	echo "check_external_commands=" >> "$conffile"

	sed --follow-symlinks -i -e "s|^ *check_external_commands=.|check_external_commands=$check_external_commands|" \
		"$conffile"
	# Stop a not already stopped icinga instance,
	# debhelper will start it again automatically at the bottom
	status="$(/etc/init.d/icinga status >/dev/null 2>&1; echo $?)"

	if [ "$status" -ne 3 ]; then
		if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then
			invoke-rc.d icinga stop || true
		else
			/etc/init.d/icinga stop || true
		fi
	fi

	case $check_external_commands in
		1)
			if ! dpkg-statoverride --list /var/lib/icinga/rw >/dev/null 2>&1; then
				dpkg-statoverride --quiet --update --add nagios www-data 2710 /var/lib/icinga/rw
			fi

			if ! dpkg-statoverride --list /var/lib/icinga >/dev/null 2>&1; then
				dpkg-statoverride --quiet --update --add nagios nagios 751 /var/lib/icinga
			fi
			;;

		0)
			if dpkg-statoverride --list /var/lib/icinga/rw >/dev/null 2>&1; then
				dpkg-statoverride --quiet --remove /var/lib/icinga/rw
			fi

			if dpkg-statoverride --list /var/lib/icinga >/dev/null 2>&1; then
				dpkg-statoverride --quiet --remove /var/lib/icinga
			fi
			;;
	esac
    ;;
  abort-upgrade|abort-remove|abort-deconfigure)
    ;;
  *)
    echo "postinst called with unknown argument \$1'" >&2
    exit 1
    ;;
esac

init_failed ()
{
    echo "Icinga was unable to start due to configuration errors.";
    echo "Please fix them and manually restart the icinga daemon using";
    echo " ´service start icinga´";
}

# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/icinga" ]; then
		update-rc.d icinga defaults >/dev/null
	fi
	if [ -x "/etc/init.d/icinga" ] || [ -e "/etc/init/icinga.conf" ]; then
		invoke-rc.d icinga start || init_failed
	fi
fi
# End automatically added section