maybe chown 'nagios' 'icinga2'
maybe chgrp 'nagios' 'icinga2'
maybe chmod 0750 'icinga2'
-maybe chmod 0755 'icinga2/conf.d'
+maybe chown 'nagios' 'icinga2/conf.d'
+maybe chgrp 'nagios' 'icinga2/conf.d'
+maybe chmod 0750 'icinga2/conf.d'
+maybe chown 'nagios' 'icinga2/conf.d/api-users.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/api-users.conf'
maybe chmod 0644 'icinga2/conf.d/api-users.conf'
+maybe chown 'nagios' 'icinga2/conf.d/app.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/app.conf'
maybe chmod 0644 'icinga2/conf.d/app.conf'
+maybe chown 'nagios' 'icinga2/conf.d/apt.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/apt.conf'
maybe chmod 0644 'icinga2/conf.d/apt.conf'
+maybe chown 'nagios' 'icinga2/conf.d/commands.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/commands.conf'
maybe chmod 0644 'icinga2/conf.d/commands.conf'
+maybe chown 'nagios' 'icinga2/conf.d/downtimes.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/downtimes.conf'
maybe chmod 0644 'icinga2/conf.d/downtimes.conf'
+maybe chown 'nagios' 'icinga2/conf.d/groups.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/groups.conf'
maybe chmod 0644 'icinga2/conf.d/groups.conf'
+maybe chown 'nagios' 'icinga2/conf.d/hosts.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/hosts.conf'
maybe chmod 0644 'icinga2/conf.d/hosts.conf'
+maybe chown 'nagios' 'icinga2/conf.d/notifications.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/notifications.conf'
maybe chmod 0644 'icinga2/conf.d/notifications.conf'
+maybe chown 'nagios' 'icinga2/conf.d/services.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/services.conf'
maybe chmod 0644 'icinga2/conf.d/services.conf'
+maybe chown 'nagios' 'icinga2/conf.d/templates.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/templates.conf'
maybe chmod 0644 'icinga2/conf.d/templates.conf'
+maybe chown 'nagios' 'icinga2/conf.d/timeperiods.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/timeperiods.conf'
maybe chmod 0644 'icinga2/conf.d/timeperiods.conf'
+maybe chown 'nagios' 'icinga2/conf.d/users.conf'
+maybe chgrp 'nagios' 'icinga2/conf.d/users.conf'
maybe chmod 0644 'icinga2/conf.d/users.conf'
-maybe chmod 0644 'icinga2/constants.conf'
-maybe chmod 0755 'icinga2/features-available'
+maybe chown 'nagios' 'icinga2/constants.conf'
+maybe chgrp 'nagios' 'icinga2/constants.conf'
+maybe chmod 0640 'icinga2/constants.conf'
+maybe chown 'nagios' 'icinga2/features-available'
+maybe chgrp 'nagios' 'icinga2/features-available'
+maybe chmod 0750 'icinga2/features-available'
+maybe chown 'nagios' 'icinga2/features-available/api.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/api.conf'
maybe chmod 0644 'icinga2/features-available/api.conf'
+maybe chown 'nagios' 'icinga2/features-available/checker.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/checker.conf'
maybe chmod 0644 'icinga2/features-available/checker.conf'
+maybe chown 'nagios' 'icinga2/features-available/command.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/command.conf'
maybe chmod 0644 'icinga2/features-available/command.conf'
+maybe chown 'nagios' 'icinga2/features-available/compatlog.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/compatlog.conf'
maybe chmod 0644 'icinga2/features-available/compatlog.conf'
+maybe chown 'nagios' 'icinga2/features-available/debuglog.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/debuglog.conf'
maybe chmod 0644 'icinga2/features-available/debuglog.conf'
+maybe chown 'nagios' 'icinga2/features-available/elasticsearch.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/elasticsearch.conf'
maybe chmod 0644 'icinga2/features-available/elasticsearch.conf'
+maybe chown 'nagios' 'icinga2/features-available/gelf.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/gelf.conf'
maybe chmod 0644 'icinga2/features-available/gelf.conf'
+maybe chown 'nagios' 'icinga2/features-available/graphite.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/graphite.conf'
maybe chmod 0644 'icinga2/features-available/graphite.conf'
+maybe chown 'nagios' 'icinga2/features-available/influxdb.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/influxdb.conf'
maybe chmod 0644 'icinga2/features-available/influxdb.conf'
+maybe chown 'nagios' 'icinga2/features-available/livestatus.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/livestatus.conf'
maybe chmod 0644 'icinga2/features-available/livestatus.conf'
+maybe chown 'nagios' 'icinga2/features-available/mainlog.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/mainlog.conf'
maybe chmod 0644 'icinga2/features-available/mainlog.conf'
+maybe chown 'nagios' 'icinga2/features-available/notification.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/notification.conf'
maybe chmod 0644 'icinga2/features-available/notification.conf'
+maybe chown 'nagios' 'icinga2/features-available/opentsdb.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/opentsdb.conf'
maybe chmod 0644 'icinga2/features-available/opentsdb.conf'
+maybe chown 'nagios' 'icinga2/features-available/perfdata.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/perfdata.conf'
maybe chmod 0644 'icinga2/features-available/perfdata.conf'
+maybe chown 'nagios' 'icinga2/features-available/statusdata.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/statusdata.conf'
maybe chmod 0644 'icinga2/features-available/statusdata.conf'
+maybe chown 'nagios' 'icinga2/features-available/syslog.conf'
+maybe chgrp 'nagios' 'icinga2/features-available/syslog.conf'
maybe chmod 0644 'icinga2/features-available/syslog.conf'
-maybe chmod 0755 'icinga2/features-enabled'
-maybe chmod 0644 'icinga2/icinga2.conf'
+maybe chown 'nagios' 'icinga2/features-enabled'
+maybe chgrp 'nagios' 'icinga2/features-enabled'
+maybe chmod 0750 'icinga2/features-enabled'
+maybe chown 'nagios' 'icinga2/icinga2.conf'
+maybe chgrp 'nagios' 'icinga2/icinga2.conf'
+maybe chmod 0640 'icinga2/icinga2.conf'
maybe chmod 0644 'icinga2/init.conf'
maybe chown 'nagios' 'icinga2/pki'
maybe chgrp 'nagios' 'icinga2/pki'
maybe chmod 0700 'icinga2/pki'
+maybe chown 'nagios' 'icinga2/pki/ca.crt'
+maybe chgrp 'nagios' 'icinga2/pki/ca.crt'
maybe chmod 0644 'icinga2/pki/ca.crt'
+maybe chown 'nagios' 'icinga2/pki/home.hoellein.online.crt'
+maybe chgrp 'nagios' 'icinga2/pki/home.hoellein.online.crt'
maybe chmod 0644 'icinga2/pki/home.hoellein.online.crt'
+maybe chown 'nagios' 'icinga2/pki/home.hoellein.online.key'
+maybe chgrp 'nagios' 'icinga2/pki/home.hoellein.online.key'
maybe chmod 0600 'icinga2/pki/home.hoellein.online.key'
maybe chmod 0755 'icinga2/scripts'
maybe chmod 0755 'icinga2/scripts/mail-host-notification.sh'
maybe chmod 0755 'icinga2/scripts/mail-service-notification.sh'
-maybe chmod 0644 'icinga2/zones.conf'
-maybe chmod 0755 'icinga2/zones.d'
+maybe chown 'nagios' 'icinga2/zones.conf'
+maybe chgrp 'nagios' 'icinga2/zones.conf'
+maybe chmod 0640 'icinga2/zones.conf'
+maybe chown 'nagios' 'icinga2/zones.d'
+maybe chgrp 'nagios' 'icinga2/zones.d'
+maybe chmod 0750 'icinga2/zones.d'
maybe chmod 0644 'icinga2/zones.d/README'
maybe chgrp 'icingaweb2' 'icingaweb2'
maybe chmod 2770 'icingaweb2'
maybe chmod 0755 'systemd/system/getty.target.wants'
maybe chmod 0755 'systemd/system/graphical.target.wants'
maybe chmod 0644 'systemd/system/hddtemp.service'
+maybe chmod 0755 'systemd/system/icinga2.service.d'
+maybe chmod 0644 'systemd/system/icinga2.service.d/limits.conf'
maybe chmod 0755 'systemd/system/mariadb.service.d'
maybe chmod 0644 'systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf'
maybe chmod 0755 'systemd/system/multi-user.target.wants'
-#!/usr/bin/env bash
-#
-# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
+#!/bin/sh
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license
PROG="`basename $0`"
ICINGA2HOST="`hostname`"
exit 1;
}
+urlencode() {
+ local LANG=C i=0 c e s="$1"
+
+ while [ $i -lt ${#1} ]; do
+ [ "$i" -eq 0 ] || s="${s#?}"
+ c=${s%"${s#?}"}
+ [ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
+ e="${e}${c}"
+ i=$((i + 1))
+ done
+ echo "$e"
+}
+
## Main
while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v: opt
do
shift $((OPTIND - 1))
-## Check required parameters (TODO: better error message)
## Keep formatting in sync with mail-service-notification.sh
-if [ ! "$LONGDATETIME" ] \
-|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
-|| [ ! "$HOSTOUTPUT" ] || [ ! "$HOSTSTATE" ] \
-|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
- Error "Requirement parameters are missing."
-fi
+for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
+ eval "PAR=\$${P}"
+
+ if [ ! "$PAR" ] ; then
+ Error "Required parameter '$P' is missing."
+ fi
+done
## Build the message's subject
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
if [ -n "$ICINGAWEB2URL" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
-$ICINGAWEB2URL/monitoring/host/show?host=$HOSTNAME"
+$ICINGAWEB2URL/monitoring/host/show?host=$(urlencode "$HOSTNAME")"
fi
## Check whether verbose mode was enabled and log to syslog.
## Debian/Ubuntu use mailutils which requires `-a` to append the header
if [ -f /etc/debian_version ]; then
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
+ | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
else
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
+ | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
fi
else
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
| $MAILBIN -s "$SUBJECT" $USEREMAIL
fi
-#!/usr/bin/env bash
-#
-# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
+#!/bin/sh
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license
PROG="`basename $0`"
ICINGA2HOST="`hostname`"
exit 1;
}
+urlencode() {
+ local LANG=C i=0 c e s="$1"
+
+ while [ $i -lt ${#1} ]; do
+ [ "$i" -eq 0 ] || s="${s#?}"
+ c=${s%"${s#?}"}
+ [ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
+ e="${e}${c}"
+ i=$((i + 1))
+ done
+ echo "$e"
+}
+
## Main
while getopts 4:6:b:c:d:e:f:hi:l:n:o:r:s:t:u:v: opt
do
shift $((OPTIND - 1))
-## Check required parameters (TODO: better error message)
## Keep formatting in sync with mail-host-notification.sh
-if [ ! "$LONGDATETIME" ] \
-|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \
-|| [ ! "$SERVICENAME" ] || [ ! "$SERVICEDISPLAYNAME" ] \
-|| [ ! "$SERVICEOUTPUT" ] || [ ! "$SERVICESTATE" ] \
-|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then
- Error "Requirement parameters are missing."
-fi
+for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
+ eval "PAR=\$${P}"
+
+ if [ ! "$PAR" ] ; then
+ Error "Required parameter '$P' is missing."
+ fi
+done
## Build the message's subject
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
if [ -n "$ICINGAWEB2URL" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
-$ICINGAWEB2URL/monitoring/service/show?host=$HOSTNAME&service=$SERVICENAME"
+$ICINGAWEB2URL/monitoring/service/show?host=$(urlencode "$HOSTNAME")&service=$(urlencode "$SERVICENAME")"
fi
## Check whether verbose mode was enabled and log to syslog.
## Debian/Ubuntu use mailutils which requires `-a` to append the header
if [ -f /etc/debian_version ]; then
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
+ | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
else
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
+ | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
fi
else
- /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
| $MAILBIN -s "$SUBJECT" $USEREMAIL
fi