1 #!/bin/sh
2 # postinst script for nagvis
3 #
4 # see: dh_installdeb(1)
6 set -e
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 # <new-version>
13 # * <postinst> `abort-remove'
14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 # <failed-install-package> <version> `removing'
16 # <conflicting-package> <version>
17 # for details, see http://www.debian.org/doc/debian-policy/ or
18 # the debian-policy package
21 case "$1" in
22 configure)
23 # Source debconf library.
24 . /usr/share/debconf/confmodule
25 db_get nagvis/monitoring_system
26 MONITORING="$RET"
27 case "$MONITORING" in
28 "icinga")
29 ## Creating Configuration file for Nagvis
30 nagvis_tmp=$(mktemp)
31 zcat /usr/share/doc/nagvis/nagvis.ini.php-sample.gz | sed \
32 -e "s#;file_group=\"\"#file_group=\"www-data\"#g" \
33 -e "s#;file_mode=\"660\"#file_mode=\"660\"#g" \
34 -e "s#;base=\"/usr/local/nagvis/\"#base=\"/usr/share/nagvis/\"#" \
35 -e "s#;htmlbase=\"/nagvis\"#htmlbase=\"/nagvis\"#" \
36 -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/icinga/cgi-bin\"#" \
37 -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/icinga/rw/live\"#" \
38 -e "s#\[rotation_demo\]#;\[rotation_demo\]#" \
39 -e "s#interval=15#;interval=15#" \
40 -e "s#maps=\"demo-germany,demo-ham-racks,demo-load,demo-muc-srv1\"#;maps=\"demo-germany,demo-ham-racks,demo-load,demo-muc-srv1\"#" \
41 > "$nagvis_tmp"
42 chgrp www-data "$nagvis_tmp"
43 chmod g+rw "$nagvis_tmp"
44 ucf --debconf-ok "$nagvis_tmp" /etc/nagvis/nagvis.ini.php
45 ucfr nagvis /etc/nagvis/nagvis.ini.php
46 rm -f "$nagvis_tmp"
47 ## Creating Configuration snipplet for Apache
48 apache_tmp=$(mktemp)
49 sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
50 -e "s#@NAGVIS_WEB@#/nagvis#g" \
51 -e "s#@NAGIOS_PATH@/etc#/etc/icinga#g" \
52 < /usr/share/doc/nagvis/apache2-nagvis.conf-sample \
53 > "$apache_tmp"
54 chmod go+r "$apache_tmp"
55 ucf --debconf-ok "$apache_tmp" /etc/apache2/conf.d/nagvis.conf
56 ucfr nagvis /etc/apache2/conf.d/nagvis.conf
57 rm -f "$apache_tmp"
58 # When the use removed the configuration file, we don't
59 # have to reload apache; might confuse users (or even fail)
60 if [ -f /etc/apache2/conf.d/nagvis.conf ] ; then
61 invoke-rc.d apache2 reload
62 fi
63 ;;
64 "nagios")
65 ## Creating Configuration file for Nagvis
66 nagvis_tmp=$(mktemp)
67 zcat /usr/share/doc/nagvis/nagvis.ini.php-sample.gz | sed \
68 -e "s#;file_group=\"\"#file_group=\"www-data\"#g" \
69 -e "s#;file_mode=\"660\"#file_mode=\"660\"#g" \
70 -e "s#;base=\"/usr/local/nagvis/\"#base=\"/usr/share/nagvis/\"#" \
71 -e "s#;htmlbase=\"/nagvis\"#htmlbase=\"/nagvis\"#" \
72 -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
73 -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/nagios3/rw/live\"#" \
74 -e "s#\[rotation_demo\]#;\[rotation_demo\]#" \
75 -e "s#interval=15#;interval=15#" \
76 -e "s#maps=\"demo-germany,demo-ham-racks,demo-load,demo-muc-srv1\"#;maps=\"demo-germany,demo-ham-racks,demo-load,demo-muc-srv1\"#" \
77 > "$nagvis_tmp"
78 chgrp www-data "$nagvis_tmp"
79 chmod g+rw "$nagvis_tmp"
80 ucf --debconf-ok "$nagvis_tmp" /etc/nagvis/nagvis.ini.php
81 ucfr nagvis /etc/nagvis/nagvis.ini.php
82 rm -f "$nagvis_tmp"
83 ## Creating Configuration snipplet for Apache
84 apache_tmp=$(mktemp)
85 sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
86 -e "s#@NAGVIS_WEB@#/nagvis#g" \
87 -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g" \
88 < /usr/share/doc/nagvis/apache2-nagvis.conf-sample \
89 > "$apache_tmp"
90 chmod go+r "$apache_tmp"
91 ucf --debconf-ok "$apache_tmp" /etc/apache2/conf.d/nagvis.conf
92 ucfr nagvis /etc/apache2/conf.d/nagvis.conf
93 rm -f "$apache_tmp"
94 # When the use removed the configuration file, we don't
95 # have to reload apache; might confuse users (or even fail)
96 if [ -f /etc/apache2/conf.d/nagvis.conf ] ; then
97 invoke-rc.d apache2 reload
98 fi
99 ;;
100 "other")
101 # nothing to be done for others
102 ;;
103 esac
104 ;;
106 abort-upgrade|abort-remove|abort-deconfigure)
107 ;;
109 *)
110 echo "postinst called with unknown argument \`$1'" >&2
111 exit 1
112 ;;
113 esac
115 # dh_installdeb will replace this with shell code automatically
116 # generated by other debhelper scripts.
118 #DEBHELPER#
120 exit 0