This file is indexed.

postinst is in cacti 1.1.38+ds1-1.

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
#!/bin/sh

set -e

# source debconf stuff
. /usr/share/debconf/confmodule
db_version 2.0
# source dbconfig-common stuff
. /usr/share/dbconfig-common/dpkg/postinst.mysql
dbc_first_version="0.8.6g-3"
dbc_generate_include="template:/etc/cacti/debian.php"
dbc_generate_include_owner="root:www-data"
dbc_generate_include_perms="0640"
dbc_generate_include_args="--dbname=database_default --dbpass=database_password --dbuser=database_username --dbserver=database_hostname --dbport=database_port -o template_infile=/usr/share/cacti/conf_templates/debian.php.dist"
dbc_mysql_createdb_encoding="latin1"
dbc_sql_substitutions="true"
dbc_go cacti $@
ucfr cacti /etc/cacti/debian.php

#
# Skip, if we are not in "configure" or "reconfigure" state
#
if [ "$1" != "configure" ] && [ "$1" != "reconfigure" ]; then
    exit 0
fi

#
# retrieve various configuration options from debconf
#
db_get cacti/webserver
WWWTYPE="$RET"

ucf --debconf-ok /usr/share/cacti/conf_templates/cacti.apache.conf /etc/apache2/conf-available/cacti.conf
ucfr cacti /etc/apache2/conf-available/cacti.conf
ucf --debconf-ok /usr/share/cacti/conf_templates/cacti.lighttpd.conf /etc/lighttpd/conf-available/20-cacti.conf
ucfr cacti /etc/lighttpd/conf-available/20-cacti.conf

# done with debconf...
db_stop

# Only create common files (logfile) and grant permissions on first install
if [ ! -n "$2" ] ; then
    touch /var/log/cacti/rrd.log /var/log/cacti/cacti.log /var/log/cacti/poller-error.log
    chmod 0640 /var/log/cacti/rrd.log /var/log/cacti/cacti.log /var/log/cacti/poller-error.log
    chown -R www-data:www-data /var/log/cacti/

    # Check if
    # - the admin wanted dbconfig to help
    # - there is a password to use
    # - if the dbconfig installation went ok (e.g. no noninteractive fail)
    #   see also bug 822945
    if [ "$dbc_install" = "true" ] && [ -n "$dbc_dbpass" ] && [ "${_dbc_on_error_option}" != "ignore" ] ; then
        # An upstream clean install has a well-known admin password and
        # triggers a change before one can continue. However, on Debian we
        # already have a good password that we can communicate to the admin, so
        # make the setup safe from the start.
        dbc_mysql_exec_command "UPDATE user_auth SET password=md5('$dbc_dbpass'), must_change_password='' WHERE id=1"

        # An upstream clean install triggers some questions before you can use
        # Cacti for the first time. However, on Debian that should already be
        # alright. Prevent triggering these questions by filling the latest
        # version number into the database.
        cacti_upstream_ver=$(dpkg-query -f '${Version}' -W 'cacti' | sed s/\+ds[0-9]-.*//)
        dbc_mysql_exec_command "UPDATE version SET cacti='$cacti_upstream_ver'"

        # Until now (2016-04-01) the versions of rrdtool in Cacti are always of
        # the form rrd-[0-9].[0-9].x, so let's assume that.
        rrd_ver=$(dpkg-query -f '${Version}' -W 'rrdtool')
        dbc_mysql_exec_command "INSERT INTO settings SET name='rrdtool_version', value='rrd-${rrd_ver%%[0-9]-*}x'"

        # Since cacti version 1.0.0, by default there aren't any templates
        # loaded anymore which leaves an empty experience. More so because
        # there is no web interface that tells you of the existence, nor is
        # able to load the "packages". So let's load the default ones here.
        #
        # Because we want to keep the debsums checksums constant, we don't
        # actually want to change the scripts (they are not equal, see
        # https://github.com/Cacti/cacti/issues/810). So, make sure we run
        # these commands as the www-data user, because that can execute the
        # MySQL calls, but can't change the files (and that is OK).
        echo -n "Loading default cacti templates (may take some time)."
        su --shell /bin/sh www-data -c "/usr/share/cacti/cli/import_package.php \
            --filename=/usr/share/cacti/site/install/templates/Local_Linux_Machine.xml.gz" > /dev/null
        echo -n "."
        su --shell /bin/sh www-data -c "/usr/share/cacti/cli/import_package.php \
            --filename=/usr/share/cacti/site/install/templates/Generic_SNMP_Device.xml.gz" > /dev/null
        echo -n "."
        su --shell /bin/sh www-data -c "/usr/share/cacti/cli/import_package.php \
            --filename=/usr/share/cacti/site/install/templates/NetSNMP_Device.xml.gz" > /dev/null
        echo -n "."
        su --shell /bin/sh www-data -c "/usr/share/cacti/cli/import_package.php \
            --filename=/usr/share/cacti/site/install/templates/Cisco_Router.xml.gz" > /dev/null
        echo "  done."

        # And since we don't pass through the install script anymore, we need
        # to rebuild the poller cache now (but suppress normal output as it
        # looks scary during install).
        php /usr/share/cacti/cli/rebuild_poller_cache.php > /dev/null
    fi
fi

# Make sure the database is up-to-date
if [ -n "$2" ] ; then
    { echo "Running cli/upgrade_database.php as part of package update..." ; \
      php /usr/share/cacti/cli/upgrade_database.php ; } | \
        if [ -f /usr/bin/ts ] ; then LC_TIME=C ts "%m/%d/%Y %I:%M:%S %p" | tee -a /var/log/cacti/cacti.log ; \
        else tee -a /var/log/cacti/cacti.log ; fi
fi

# Update the webserver, if needed
case $WWWTYPE in
    apache2)
        #       Sniplet adjusted from http://wiki.debian.org/Apache/PackagingFor24
        if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
            . /usr/share/apache2/apache2-maintscript-helper
            apache2_invoke enconf cacti
        elif  dpkg-query -f '${Version}'  -W 'apache2.2-common' > /dev/null 2>&1 ; then
            [ -d /etc/apache2/conf.d/ ] && [ ! -h /etc/apache2/conf.d/cacti.conf ] && \
                ln -s ../conf-available/cacti.conf /etc/apache2/conf.d/cacti.conf
        else
            echo "Apache2 not installed, skipping"
        fi
        ;;
    lighttpd)
        if [ -e /etc/lighttpd/conf-available/20-cacti.conf ] ; then
            if which lighty-enable-mod >/dev/null 2>&1 ; then
                lighty-enable-mod cacti || \
                    if [ "$?" != "2" ] ; then exit 1 ; else true ; fi
            else
                echo "Lighttpd not installed, skipping"
            fi
        fi
        ;;
    *)
        ;;
esac

# Always trigger reload of webservers if the configuration is enabled
if [ -e /etc/apache2/conf.d/cacti.conf -o -e /etc/apache2/conf-enabled/cacti.conf ] ; then
    invoke-rc.d apache2 reload || true
fi
if [ -e /etc/lighttpd/conf-enabled/20-cacti.conf ] ; then
    #   We need to take care: bug #446324
    invoke-rc.d lighttpd reload 3>/dev/null || true
fi

# Automatically added by dh_usrlocal/11.1.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then
(
	while read line; do
		set -- $line
		dir="$1"; mode="$2"; user="$3"; group="$4"
		if [ ! -e "$dir" ]; then
			if mkdir "$dir" 2>/dev/null; then
				chown "$user":"$group" "$dir"
				chmod "$mode" "$dir"
			fi
		fi
	done
) << DATA
/usr/local/share 02775 root staff
/usr/local/share/cacti 02775 root staff
/usr/local/share/cacti/resource 02775 root staff
/usr/local/share/cacti/resource/script_queries 02775 root staff
/usr/local/share/cacti/resource/script_server 02775 root staff
/usr/local/share/cacti/resource/snmp_queries 02775 root staff
/usr/local/share/cacti/scripts 02775 root staff
DATA
fi
# End automatically added section
# Automatically added by dh_installdeb/11.1.6ubuntu1
dpkg-maintscript-helper dir_to_symlink /usr/share/cacti/site/include/js/themes /usr/share/javascript/jstree/themes 0.8.8h\+ds1-10\~ cacti -- "$@"
# End automatically added section

exit 0