This file is indexed.

postinst is in nagvis 1:1.7.10+dfsg1-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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh
# postinst script for nagvis
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

if dpkg --compare-versions "$2" lt-nl "1:1.7.9+dfsg1-1~"; then
    # help by adding a empty file
    touch /etc/nagvis/apache2.conf

    # move /etc/apache2/conf.d/nagvis.conf to /etc/nagvis/apache2.conf
    dpkg-maintscript-helper mv_conffile \
        /etc/apache2/conf.d/nagvis.conf /etc/nagvis/apache2.conf "1:1.7.9+dfsg1-1~" nagvis -- "$@"

    # unregister old file
    ucf -p /etc/apache2/conf.d/nagvis.conf
    ucfr -p nagvis /etc/apache2/conf.d/nagvis.conf
    # delete helper file
    rm -f /etc/nagvis/apache2.conf.dpkg-new

    # remove old automap
    dpkg-maintscript-helper rm_conffile \
        /etc/nagvis/automaps/__automap.cfg "1:1.7.9+dfsg1-1~" nagvis -- "$@"

    rmdir /etc/nagvis/automaps/ 2>/dev/null || true
fi

setperm() {
    user="$1"
    group="$2"
    mode="$3"
    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
}

update_permissions() {
    setperm www-data www-data 0755 /etc/nagvis
    setperm www-data www-data 0755 /etc/nagvis/maps
    setperm www-data www-data 0755 /etc/nagvis/conf.d
    setperm www-data www-data 0755 /etc/nagvis/profiles

    setperm www-data www-data 0755 /var/lib/nagvis/userfiles
    setperm www-data www-data 0755 /var/lib/nagvis/userfiles/images/maps
    setperm www-data www-data 0755 /var/lib/nagvis/userfiles/images/shapes

    setperm www-data www-data 0750 /var/cache/nagvis
    setperm www-data www-data 0750 /var/cache/nagvis/tmpl
    setperm www-data www-data 0750 /var/cache/nagvis/tmpl/compile
    setperm www-data www-data 0750 /var/cache/nagvis/tmpl/cache
}

# migrate userfiles from /var/cache/nagvis to /var/lib/nagvis
migrate_userfiles() {
    from="/var/cache/nagvis/userfiles"
    to="/var/lib/nagvis/userfiles"

    for dir in images/maps images/shapes; do
        if [ -d "$from/$dir" ]; then
            echo "moving files from $from/$dir to $to/$dir ..."
            mv "$from/$dir"/* "$to/$dir/"
            rmdir "$from/$dir" || true
        fi
    done

    test -d "$from/images" && rmdir "$from/images" || true
    test -d "$from" && rmdir "$from" || true
}

case "$1" in
    configure)
        # Source debconf library.
        . /usr/share/debconf/confmodule
        db_get nagvis/monitoring_system
        MONITORING="$RET"
        case "$MONITORING" in
            "icinga"|"nagios"|"shinken")
                ## Creating Configuration file for Nagvis
                nagvis_tmp=$(mktemp)
                cat /usr/share/nagvis/defaults/nagvis.ini.php-sample | sed \
                  -e "s#;file_group=\"\"#file_group=\"www-data\"#g" \
                  -e "s#;file_mode=\"660\"#file_mode=\"660\"#g" \
                  -e "s#;base=\"/usr/local/nagvis/\"#base=\"/usr/share/nagvis/\"#" \
                  -e "s#;htmlbase=\"/nagvis\"#htmlbase=\"/nagvis\"#" \
                  -e "s#\[rotation_demo\]#;\[rotation_demo\]#" \
                  -e "s#interval=15#;interval=15#" \
                  -e "s#maps=\"\(.*\)\"#;maps=\"\1\"#" \
                  > "$nagvis_tmp"
                case "$MONITORING" in
                    "icinga")
                        sed -i "$nagvis_tmp" \
                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/icinga/cgi-bin\"#" \
                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/icinga/rw/live\"#"
                    ;;
                    "nagios")
                        sed -i "$nagvis_tmp" \
                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/nagios3/rw/live\"#"
                    ;;
                    "shinken")
                        sed -i "$nagvis_tmp" \
                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"tcp:localhost:50000\"#"
                    ;;
                esac
                chgrp www-data "$nagvis_tmp"
                chmod g+rw "$nagvis_tmp"
                ucf --debconf-ok "$nagvis_tmp" /etc/nagvis/nagvis.ini.php
                ucfr nagvis /etc/nagvis/nagvis.ini.php
                rm -f "$nagvis_tmp"
                ## Creating Configuration snipplet for Apache
                apache_tmp=$(mktemp)
                sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
                  -e "s#@NAGVIS_WEB@#/nagvis#g" \
                  < /usr/share/nagvis/defaults/apache2-nagvis.conf-sample \
                  > "$apache_tmp"
                case "$MONITORING" in
                    "icinga")
                        sed -i "$apache_tmp" \
                          -e "s#@NAGIOS_PATH@/etc#/etc/icinga#g"
                    ;;
                    "nagios")
                        sed -i "$apache_tmp" \
                          -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g"
                    ;;
                    "shinken")
                        sed -i "$apache_tmp" \
                          -e "s#@NAGIOS_PATH@/etc#/etc/shinken#g"
                    ;;
                esac
                chmod go+r "$apache_tmp"
                ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
                ucfr nagvis /etc/nagvis/apache2.conf
                rm -f "$apache_tmp"
            ;;
            "other")
                 # nothing to be done for others
            ;;
        esac

        # enable apache when file exists and we are on autoconfigure
        if [ -f /etc/nagvis/apache2.conf ] && ( [ "$MONITORING" = "nagios" ] || [ "$MONITORING" = "icinga" ] || [ "$MONITORING" = "shinken" ] ); then
            echo "enabling Apache2 config..."

            COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)

            # NEW method for Apache >= 2.4
            if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
                . /usr/share/apache2/apache2-maintscript-helper

                apache2_invoke enmod rewrite
                apache2_invoke enconf nagvis

                # remove OLD Apache 2.2 link
                [ -L /etc/apache2/conf.d/nagvis.conf ] && rm /etc/apache2/conf.d/nagvis.conf

            # OLD methods for Apache < 2.4
            elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
                # enable mod rewrite
                [ -f /etc/apache2/mods-enabled/rewrite.load ] || a2enmod rewrite

                # create symlink if not existing
                [ -f /etc/apache2/conf.d/nagvis.conf ] || ln -vs ../../nagvis/apache2.conf /etc/apache2/conf.d/nagvis.conf

                # reload webserver
                [ -x $(which invoke-rc.d) ] && invoke-rc.d apache2 reload
            fi

        fi

        update_permissions
        migrate_userfiles
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0