File _service:extract_file:debian.thruk-base.postinst of Package thruk
#!/bin/sh
# postinst script for thruk
#
# 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
setup_apache2() {
echo "Configuring apache2 vhost ..."
# enable modules we need
a2enmod alias
a2enmod fcgid
a2enmod auth_basic
a2enmod rewrite
# enable thruk itself
if [ -x '/usr/sbin/a2enconf' ]; then
# clean up old conf.d mess
set +e
if [ -e /etc/apache2/conf.d/thruk.conf -a -e /etc/apache2/conf-available/thruk.conf.dpkg-new -a -h /etc/apache2/conf-available/thruk.conf ]; then
diff /etc/apache2/conf.d/thruk.conf /etc/apache2/conf-available/thruk.conf.dpkg-new >/dev/null && {
rm -f /etc/apache2/conf.d/thruk.conf /etc/apache2/conf-available/thruk.conf
rmdir /etc/apache2/conf.d 2>/dev/null
mv /etc/apache2/conf-available/thruk.conf.dpkg-new /etc/apache2/conf-available/thruk.conf
}
fi
set -e
[ -f /etc/apache2/conf-enabled/thruk.conf ] || /usr/sbin/a2enconf thruk
[ -f /etc/apache2/conf-enabled/thruk_cookie_auth_vhost.conf ] || /usr/sbin/a2enconf thruk_cookie_auth_vhost
fi
# activate cookie in existing default virtual hosts
set +e
ls -1 /etc/apache2/sites-available/*default* | \
while read file; do
if ! grep thruk_cookie_auth.include $file >/dev/null 2>&1; then
sed -i -e 's|</VirtualHost>|\n Include /usr/share/thruk/thruk_cookie_auth.include\n</VirtualHost>|g' $file
fi
done
set -e
# reload new apache config
if which invoke-rc.d >/dev/null 2>&1; then
invoke-rc.d apache2 reload || true
else
/etc/init.d/apache2 reload || true
fi
echo "Thruk have been configured for http://$(hostname)/thruk/."
echo "The default user is 'thrukadmin' with password 'thrukadmin'. You can usually change that by 'htpasswd /etc/thruk/htpasswd thrukadmin'"
}
case "$1" in
configure)
# restore themes, plugins and ssi
if [ -d /tmp/thruk_update/themes/. ]; then
# do not remove the new default theme
test -h /tmp/thruk_update/themes/Thruk2 || mv /etc/thruk/themes/themes-enabled/Thruk2 /etc/thruk/themes/themes-enabled/.Thruk2
rm -f /etc/thruk/themes/themes-enabled/*
cp -rp /tmp/thruk_update/themes/* /etc/thruk/themes/themes-enabled/
test -h /etc/thruk/themes/themes-enabled/.Thruk2 && mv /etc/thruk/themes/themes-enabled/.Thruk2 /etc/thruk/themes/themes-enabled/Thruk2
fi
if [ -d /tmp/thruk_update/plugins/. ]; then
rm -f /etc/thruk/plugins/plugins-enabled/*
cp -rp /tmp/thruk_update/plugins/* /etc/thruk/plugins/plugins-enabled/
fi
echo "thruk plugins enabled:" $(ls /etc/thruk/plugins/plugins-enabled/)
if [ -d /tmp/thruk_update/ssi/. ]; then
rm -f /etc/thruk/ssi/*
cp -rp /tmp/thruk_update/ssi/* /etc/thruk/ssi/
fi
rm -rf /tmp/thruk_update
# set permissions
mkdir -p /var/lib/thruk \
/var/log/thruk \
/var/cache/thruk/reports \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk/thruk_local.d
chown -R www-data: /var/lib/thruk \
/var/cache/thruk \
/var/log/thruk \
/etc/thruk/plugins/plugins-enabled \
/etc/thruk/thruk_local.conf \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk/thruk_local.d
chmod 755 /usr/share/thruk/fcgid_env.sh
chmod 755 /usr/share/thruk/thruk_authd.pl
chmod 755 /usr/bin/thruk
# Depending on which webserver is installed, set up the basics
# (so far only supports apache2)
[ -x /usr/sbin/apache2 ] && setup_apache2
# create empty crontab
/usr/bin/crontab -l -u www-data 2>/dev/null | /usr/bin/crontab -u www-data -
# cleanup tmp files
/usr/bin/thruk -a livecachestop --local >/dev/null 2>&1 || :
rm -rf /var/cache/thruk/*
# update cron entries
/usr/bin/thruk -a clearcache,installcron --local > /dev/null
;;
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.
#DEBHELPER#
exit 0