[Pkg-nagios-changes] [pkg-icinga-web] 06/11: Setup commandpipe for Icinga2
Markus Frosch (old DM Account)
lazyfrosch-guest at moszumanska.debian.org
Tue Sep 9 13:02:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
lazyfrosch-guest pushed a commit to branch master
in repository pkg-icinga-web.
commit c96f5f57f89940f948779826959056417b307f30
Author: Markus Frosch <markus at lazyfrosch.de>
Date: Tue Sep 9 14:17:56 2014 +0200
Setup commandpipe for Icinga2
---
debian/access.local.xml.tmpl | 17 ++++++++++
.../icinga-web-config-icinga2-ido-mysql.postinst | 39 ++++++++++++++++++++++
debian/icinga-web-config-icinga2-ido-mysql.postrm | 2 ++
.../icinga-web-config-icinga2-ido-pgsql.postinst | 39 ++++++++++++++++++++++
debian/icinga-web-config-icinga2-ido-pgsql.postrm | 2 ++
debian/icinga-web.install | 3 +-
debian/patches/03_access_include | 18 ++++++++++
debian/patches/series | 1 +
8 files changed, 119 insertions(+), 2 deletions(-)
diff --git a/debian/access.local.xml.tmpl b/debian/access.local.xml.tmpl
new file mode 100644
index 0000000..595a62b
--- /dev/null
+++ b/debian/access.local.xml.tmpl
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ae:configurations xmlns="http://icinga.org/api/config/parts/access/1.0"
+ xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0">
+ <ae:configuration>
+
+ <defaults>
+ <access>
+ <write>
+ <files>
+ <resource name="icinga_pipe">_PIPE_</resource>
+ </files>
+ </write>
+ </access>
+ </defaults>
+
+ </ae:configuration>
+</ae:configurations>
diff --git a/debian/icinga-web-config-icinga2-ido-mysql.postinst b/debian/icinga-web-config-icinga2-ido-mysql.postinst
index 8ef14e5..ef3b9fc 100644
--- a/debian/icinga-web-config-icinga2-ido-mysql.postinst
+++ b/debian/icinga-web-config-icinga2-ido-mysql.postinst
@@ -19,6 +19,41 @@ setperm() {
fi
}
+is_fresh_install()
+{
+ if [ -z "$2" ] ; then
+ return 0
+ fi
+ return 1
+}
+
+enable_icinga2_commandpipe() {
+ if is_fresh_install $@; then
+ echo "enabling icinga2 features for classicui"
+ icinga2-enable-feature command
+
+ echo "reloading icinga2"
+ [ -x $(which invoke-rc.d) ] && invoke-rc.d icinga2 reload
+ fi
+}
+
+write_access_local() {
+ local file=/etc/icinga-web/conf.d/access.local.xml
+ local template=/usr/share/icinga-web/tmpl/access.local.xml.tmpl
+ local pipe=/run/icinga2/cmd/icinga2.cmd
+
+ # create tempfile
+ local tempfile=$(tempfile -m 600 -p "$(basename $file)")
+
+ cat $template | sed "s|_PIPE_|$pipe|" > $tempfile
+
+ # replace the file with ucf
+ ucf --debconf-ok $tempfile $file
+
+ echo "database config successful: $file"
+ rm -f $tempfile
+}
+
generate_dbxml() {
local file="$1"
local template="$2"
@@ -67,6 +102,7 @@ case "$1" in
/etc/dbconfig-common/icinga2-ido-mysql.conf
setperm root www-data 0640 /etc/icinga-web/conf.d/database-ido.xml
+ setperm root www-data 0640 /etc/icinga-web/conf.d/access.local.xml
else
(
echo
@@ -80,6 +116,9 @@ case "$1" in
exit 1
fi
+ enable_icinga2_commandpipe
+ write_access_local
+
if [ -x /usr/lib/icinga-web/bin/clearcache.sh ]; then
/usr/lib/icinga-web/bin/clearcache.sh
fi
diff --git a/debian/icinga-web-config-icinga2-ido-mysql.postrm b/debian/icinga-web-config-icinga2-ido-mysql.postrm
index 68c2939..8ed35e2 100644
--- a/debian/icinga-web-config-icinga2-ido-mysql.postrm
+++ b/debian/icinga-web-config-icinga2-ido-mysql.postrm
@@ -4,8 +4,10 @@ set -e
if [ "$1" = "purge" ]; then
rm -f /etc/icinga-web/conf.d/database-ido.xml
+ rm -f /etc/icinga-web/conf.d/access.local.xml
if which ucf >/dev/null; then
ucf --purge /etc/icinga-web/conf.d/database-ido.xml
+ ucf --purge /etc/icinga-web/conf.d/access.local.xml
fi
fi
diff --git a/debian/icinga-web-config-icinga2-ido-pgsql.postinst b/debian/icinga-web-config-icinga2-ido-pgsql.postinst
index b913c48..a30d73f 100644
--- a/debian/icinga-web-config-icinga2-ido-pgsql.postinst
+++ b/debian/icinga-web-config-icinga2-ido-pgsql.postinst
@@ -19,6 +19,41 @@ setperm() {
fi
}
+is_fresh_install()
+{
+ if [ -z "$2" ] ; then
+ return 0
+ fi
+ return 1
+}
+
+enable_icinga2_commandpipe() {
+ if is_fresh_install $@; then
+ echo "enabling icinga2 features for classicui"
+ icinga2-enable-feature command
+
+ echo "reloading icinga2"
+ [ -x $(which invoke-rc.d) ] && invoke-rc.d icinga2 reload
+ fi
+}
+
+write_access_local() {
+ local file=/etc/icinga-web/conf.d/access.local.xml
+ local template=/usr/share/icinga-web/tmpl/access.local.xml.tmpl
+ local pipe=/run/icinga2/cmd/icinga2.cmd
+
+ # create tempfile
+ local tempfile=$(tempfile -m 600 -p "$(basename $file)")
+
+ cat $template | sed "s|_PIPE_|$pipe|" > $tempfile
+
+ # replace the file with ucf
+ ucf --debconf-ok $tempfile $file
+
+ echo "database config successful: $file"
+ rm -f $tempfile
+}
+
generate_dbxml() {
local file="$1"
local template="$2"
@@ -67,6 +102,7 @@ case "$1" in
/etc/dbconfig-common/icinga2-ido-pgsql.conf
setperm root www-data 0640 /etc/icinga-web/conf.d/database-ido.xml
+ setperm root www-data 0640 /etc/icinga-web/conf.d/access.local.xml
else
(
echo
@@ -80,6 +116,9 @@ case "$1" in
exit 1
fi
+ enable_icinga2_commandpipe
+ write_access_local
+
if [ -x /usr/lib/icinga-web/bin/clearcache.sh ]; then
/usr/lib/icinga-web/bin/clearcache.sh
fi
diff --git a/debian/icinga-web-config-icinga2-ido-pgsql.postrm b/debian/icinga-web-config-icinga2-ido-pgsql.postrm
index 68c2939..8ed35e2 100644
--- a/debian/icinga-web-config-icinga2-ido-pgsql.postrm
+++ b/debian/icinga-web-config-icinga2-ido-pgsql.postrm
@@ -4,8 +4,10 @@ set -e
if [ "$1" = "purge" ]; then
rm -f /etc/icinga-web/conf.d/database-ido.xml
+ rm -f /etc/icinga-web/conf.d/access.local.xml
if which ucf >/dev/null; then
ucf --purge /etc/icinga-web/conf.d/database-ido.xml
+ ucf --purge /etc/icinga-web/conf.d/access.local.xml
fi
fi
diff --git a/debian/icinga-web.install b/debian/icinga-web.install
index 16cf072..0b660e3 100644
--- a/debian/icinga-web.install
+++ b/debian/icinga-web.install
@@ -1,7 +1,6 @@
etc/apache2/icinga-web.conf etc/icinga-web
etc/icinga-web/conf.d/* etc/icinga-web/conf.d
-debian/database-ido.xml.tmpl usr/share/icinga-web/tmpl
-debian/database-web.xml.tmpl usr/share/icinga-web/tmpl
+debian/*.xml.tmpl usr/share/icinga-web/tmpl
usr/share/icinga-web/app/* usr/share/icinga-web/app
usr/share/icinga-web/bin/clearcache.sh usr/lib/icinga-web/bin
diff --git a/debian/patches/03_access_include b/debian/patches/03_access_include
new file mode 100644
index 0000000..f9205cf
--- /dev/null
+++ b/debian/patches/03_access_include
@@ -0,0 +1,18 @@
+Description: Add xi:include to access.xml for local overrides
+Author: Markus Frosch <lazyfrosch at debian.org>
+Last-Update: 2014-09-09
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/etc/conf.d/access.xml.in
++++ b/etc/conf.d/access.xml.in
+@@ -49,6 +49,10 @@
+ </access>
+ </defaults>
+
++ <!-- include local defaults -->
++ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/etc/icinga-web/conf.d/access.local.xml">
++ <xi:fallback></xi:fallback>
++ </xi:include>
+
+ <!-- Hosts that can be accessed via the console interface -->
+ <hosts>
diff --git a/debian/patches/series b/debian/patches/series
index a75772b..7d8371c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,5 @@
00_database_includes
01_disable_reporting
02_docs_urls
+03_access_include
11_lintian_confusion
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-icinga-web.git
More information about the Pkg-nagios-changes
mailing list