#!/bin/sh
#
# Report if anything went wrong during installation, and ask the user
# to report the errors.  This must be done after 85debian-edu to make
# sure noninteractive installation is turned off, and before
# 90final-messages to leave the user with the "successful
# installation" greeting after this message.

set -e

pkglibdir=/usr/lib/debian-edu-install

. $pkglibdir/debian-edu-common

init_debconf

#set -x

if test -f /var/log/base-config.log ; then
    # Sarge install with new path names.  Make sure the old install
    # log file name point to the new file name.  This can be removed a
    # while after all documentation is updated to ask users to send in
    # base-config.log instead of installer.log. [pere 2004-09-08]
    ln -s base-config.log /var/log/installer.log
fi

# Ask the installer to report bugs if something went wrong.
if test -f $debian_edu_error_flag_file ; then
    print "info: Something failed during installation."

    db_title "Debian-Edu installation failed"

    # Quick fix to make sure all error entries at least are displayed.
    # The correct fix is to find out how to replace a debconf variable
    # with multiline content.
    # not sure why I need to change this in to one long line
    errorlist=`cat $debian_edu_error_flag_file | \
               sed 's/$/, /g' | tr -d "\n" | sed 's/, $//'`

    # This do not work on multiline substitution content
    db_subst debian-edu-install/report-bug errorlist "$errorlist"

    db_input critical debian-edu-install/report-bug || [ $? -eq 30 ]
    db_go
    rm -f $debian_edu_error_flag_file
else
    print "info: Successful installation."
fi
print "info: debian-edu-install done."

exit 0
