| 1 |
#!/bin/sh |
| 2 |
# postinst script for icinga2-common |
| 3 |
|
| 4 |
set -e |
| 5 |
|
| 6 |
setperm() { |
| 7 |
ownopt= |
| 8 |
if [ "$1" = -R ]; then |
| 9 |
ownopt="-R" |
| 10 |
shift |
| 11 |
fi |
| 12 |
user="$1" |
| 13 |
group="$2" |
| 14 |
mode="$3" |
| 15 |
file="$4" |
| 16 |
shift 4 |
| 17 |
# only do something when no setting exists |
| 18 |
if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then |
| 19 |
chown $ownopt "$user":"$group" "$file" |
| 20 |
chmod "$mode" "$file" |
| 21 |
fi |
| 22 |
} |
| 23 |
|
| 24 |
is_fresh_install() |
| 25 |
{ |
| 26 |
if [ -z "$2" ] ; then |
| 27 |
return 0 |
| 28 |
fi |
| 29 |
return 1 |
| 30 |
} |
| 31 |
|
| 32 |
case "$1" in |
| 33 |
configure) |
| 34 |
systemd-sysusers ${DPKG_ROOT:+--root="$DPKG_ROOT"} icinga2-common.conf |
| 35 |
|
| 36 |
# explicitly set permissions on some files that are dependent |
| 37 |
# on the uid/gid of the nagios user, which is dynamically created. |
| 38 |
if ! dpkg-statoverride --list /etc/icinga2; then |
| 39 |
setperm nagios nagios 0750 /etc/icinga2 |
| 40 |
setperm nagios nagios 0640 /etc/icinga2/icinga2.conf |
| 41 |
setperm nagios nagios 0640 /etc/icinga2/constants.conf |
| 42 |
setperm nagios nagios 0640 /etc/icinga2/zones.conf |
| 43 |
setperm -R nagios nagios 0700 /etc/icinga2/pki |
| 44 |
setperm -R nagios nagios 0750 /etc/icinga2/conf.d |
| 45 |
setperm -R nagios nagios 0750 /etc/icinga2/features-enabled |
| 46 |
setperm -R nagios nagios 0750 /etc/icinga2/features-available |
| 47 |
setperm nagios nagios 0750 /etc/icinga2/zones.d |
| 48 |
fi |
| 49 |
|
| 50 |
setperm nagios adm 2751 /var/log/icinga2 |
| 51 |
setperm nagios adm 2751 /var/log/icinga2/compat |
| 52 |
setperm nagios adm 2755 /var/log/icinga2/compat/archives |
| 53 |
setperm nagios adm 2751 /var/log/icinga2/crash |
| 54 |
|
| 55 |
setperm nagios nagios 0750 /var/lib/icinga2 |
| 56 |
setperm nagios nagios 0750 /var/lib/icinga2/api |
| 57 |
setperm nagios nagios 0750 /var/lib/icinga2/api/log |
| 58 |
setperm nagios nagios 0750 /var/lib/icinga2/api/repository |
| 59 |
setperm nagios nagios 0750 /var/lib/icinga2/api/zones |
| 60 |
|
| 61 |
setperm nagios www-data 0750 /var/cache/icinga2 |
| 62 |
|
| 63 |
setperm nagios nagios 0750 /var/spool/icinga2 |
| 64 |
setperm nagios nagios 0770 /var/spool/icinga2/perfdata |
| 65 |
setperm nagios nagios 0750 /var/spool/icinga2/tmp |
| 66 |
|
| 67 |
;; |
| 68 |
|
| 69 |
abort-upgrade|abort-remove|abort-deconfigure) |
| 70 |
;; |
| 71 |
|
| 72 |
*) |
| 73 |
echo "postinst called with unknown argument \`$1'" >&2 |
| 74 |
exit 1 |
| 75 |
;; |
| 76 |
esac |
| 77 |
|
| 78 |
init_failed () |
| 79 |
{ |
| 80 |
echo "Icinga 2 was unable to start due to configuration errors."; |
| 81 |
echo "Please fix them and manually restart the icinga2 daemon using"; |
| 82 |
echo " ´service icinga2 start´"; |
| 83 |
} |
| 84 |
|
| 85 |
#DEBHELPER# |
| 86 |
|
| 87 |
exit 0 |