#! /bin/sh set -e prevver="$2" add_munin_system_user() { if ! getent passwd munin >/dev/null; then adduser --group --system --no-create-home \ --home /var/lib/munin munin; fi # workaround bug (#531021) in xen-tools if ! getent group munin >/dev/null; then addgroup --system munin adduser munin munin fi } initperms() { chown munin:adm /var/log/munin chmod 755 /var/log/munin chown munin:munin /var/lib/munin chmod 755 /var/lib/munin # create munin-cgi-html.log since www-data cannot create it itself touch /var/log/munin/munin-cgi-html.log chown www-data:adm /var/log/munin/munin-cgi-html.log chmod 750 /var/log/munin/munin-cgi-html.log # create munin-cgi-graph.log since www-data cannot create it itself touch /var/log/munin/munin-cgi-graph.log chown www-data:adm /var/log/munin/munin-cgi-graph.log chmod 750 /var/log/munin/munin-cgi-graph.log chown munin:munin /var/cache/munin/www chmod 755 /var/cache/munin/www mkdir -p /var/lib/munin/cgi-tmp chown munin:www-data /var/lib/munin/cgi-tmp chmod 775 /var/lib/munin/cgi-tmp } fixoverrides() { overrides=" /var/cache/munin/www /var/lib/munin /var/log/munin /var/log/munin/munin-cgi-graph.log /var/log/munin/munin-cgi-html.log " for override in $overrides; do if dpkg-statoverride --list $override >/dev/null; then dpkg-statoverride --remove $override fi done } apache_install() { # if you add more webservers here, dont forget to also remove them in postrm webserver=apache2 webserver_init_script="/etc/init.d/$webserver" if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/munin ]; then if [ -z "$prevver" ] || ( dpkg --compare-versions $prevver ge 1.4.6-1~ && dpkg --compare-versions $prevver lt 1.4.7~ ) ; then # only create link on new installs # or when upgrading from a version where it was removed unconditionally ln -s ../../munin/apache.conf /etc/$webserver/conf.d/munin fi if [ -f $webserver_init_script ];then if [ -x $webserver_init_script ]; then invoke-rc.d $webserver reload 3>/dev/null || true else echo "munin: $webserver_init_script is not executable."\ "Could not reload $webserver" fi fi fi # installing configuration for Apache 2.4 # link config to conf-available if [ -d /etc/$webserver/conf-available ] && [ ! -e /etc/$webserver/conf-available/munin.conf ]; then ln -s ../../munin/apache.conf /etc/$webserver/conf-available/munin.conf # activate configuration on new install with apache2-mainscript-helper # TODO: Migration from installed Munin with apache2.2 to apache 2.4 if [ -z "$prevver" ]; then if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then . /usr/share/apache2/apache2-maintscript-helper apache2_invoke enconf munin.conf fi fi fi } case "$1" in configure) add_munin_system_user # this can go away after wheezy if dpkg --compare-versions "$2" le "2.0~rc5-1" ; then fixoverrides fi if dpkg --compare-versions "$2" le "2.0~rc6-2" || [ "$2" = 0 ] ; then initperms fi apache_install ;; abort-upgrade|abort-deconfigure|abort-remove) : ;; *) echo "Called with unknown argument $1, bailing out." exit 1 ;; esac # Automatically added by dh_installinit if [ -x "/etc/init.d/munin" ]; then update-rc.d munin defaults >/dev/null invoke-rc.d munin start || exit $? fi # End automatically added section