#!/bin/sh -e
case "$1" in
  configure)
    cd /var/lib/lists-archives
    if [ ! -f searchlists.log ]
    then
	touch searchlists.log
    fi
    if ! chown www-data.daemon searchlists.log; then true; fi
    if [ ! -f /etc/lists-archives/index.html ]
    then
	if ! cp -a /usr/share/doc/lists-archives/examples/index.html \
	    /etc/lists-archives/index.html; then true; fi
    fi
    if [ ! -f /etc/lists-archives/conf.pl ]
    then
	if ! cp -a /usr/share/doc/lists-archives/examples/conf.pl \
	    /etc/lists-archives/conf.pl; then true; fi
    fi
    rm -f timestamp
    echo -n "Rebuilding master index page ... "
    /usr/lib/lists-archives/updatemail -x
    echo "done."
    if [ ! -f log ]
    then
	touch log
    fi
    chown daemon.daemon /var/lib/lists-archives
    chown -R daemon.list /var/lib/lists-archives/archives
    chown -R daemon.list /var/lib/lists-archives/glimpse
    chown -R daemon.list /var/lib/lists-archives/lists
    chown -R daemon.list /var/lib/lists-archives/log
    chmod -R ug+rwX,o+rX /var/lib/lists-archives/archives
    chmod -R ug+rwX,o+rX /var/lib/lists-archives/glimpse
    chmod -R ug+rwX,o+rX /var/lib/lists-archives/lists
    chmod -R ug+rwX,o+rX /var/lib/lists-archives/log
    echo "Building full webpages in background ... "
    /etc/cron.daily/lists-archives &
    ;;

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

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