postinst is in cacti 0.8.8f+ds1-4ubuntu4.
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 | #!/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_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
# Pre 0.8.8a+dfsg-6 the configuration of apache and lighttpd was in /etc/cacti
# but this has been moved to the /etc/<server>/conf-available directories.
#
# So upon upgrade, we check if the configuration files are present and we move
# them if the target does not exist. As we provide ucf with historical md5sums,
# ucf should be capable of handling the situation well.
#
# Of course we also need to replace the original softlinks.
moveAndPurge() {
if [ -f $oldfile ] ; then
if [ ! -e $newfile ] ; then
mv $oldfile $newfile
# else: Don't do anything, leave old file in place
fi
ucf --purge $oldfile
ucfr --purge cacti $oldfile
elif [ ! -e $newfile ] ; then
# The file was removed, we should respect that. Unfortunately, we don't
# have a proper way to tell ucf that for the new location, so we need
# to hack it a bit.
# We only need to do this if the target does not already exists. If the
# target already exists, we can later call ucf straight as there
# is already a version of cacti configuration available, althought never
# provided by this package, but we can just propose the new file anyway.
ucf --debconf-ok $sourcefile $newfile
ucfr cacti $newfile
rm -f $newfile
fi
}
if [ -n "$2" ] && dpkg --compare-versions "$2" lt 0.8.8a+dfsg-6~ ; then
# Apache2
oldfile=/etc/cacti/apache.conf
newfile=/etc/apache2/conf-available/cacti.conf
sourcefile=/usr/share/cacti/conf_templates/cacti.apache.conf
moveAndPurge
link=/etc/apache2/conf.d/cacti.conf
link_value=../../cacti/apache.conf
if [ -h $link ] && [ "$(readlink $link)" = $link_value ] ; then
rm $link
ln -s ../conf-available/cacti.conf $link
fi
# Lighttpd
oldfile=/etc/cacti/lighttpd.conf
newfile=/etc/lighttpd/conf-available/20-cacti.conf
sourcefile=/usr/share/cacti/conf_templates/cacti.lighttpd.conf
moveAndPurge
link=/etc/lighttpd/conf-enabled/cacti.conf
link_value=../conf-available/cacti.conf
link2=/etc/lighttpd/conf-available/cacti.conf
link2_value=../../cacti/lighttpd.conf
if [ -h $link ] && [ "$(readlink $link )" = $link_value ] && \
[ -h $link2 ] && [ "$(readlink $link2)" = $link2_value ]; then
rm $link $link2
ln -s ../conf-available/20-cacti.conf /etc/lighttpd/conf-enabled/20-cacti.conf
elif [ -h $link2 ] && [ "$(readlink $link2)" = $link2_value ] ; then
rm $link2
fi
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/
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
# remove old unused config files
# This one was present before Sarge package
rm -f /etc/cacti/config.php
# Added removal in Wheezy; 2012
rm -f /etc/cacti/default-poller
# Automatically added by dh_usrlocal
if [ "$1" = configure ]; 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 2775 root staff
/usr/local/share/cacti 2775 root staff
/usr/local/share/cacti/resource 2775 root staff
/usr/local/share/cacti/resource/script_queries 2775 root staff
/usr/local/share/cacti/resource/script_server 2775 root staff
/usr/local/share/cacti/resource/snmp_queries 2775 root staff
/usr/local/share/cacti/scripts 2775 root staff
DATA
fi
# End automatically added section
exit 0
|