#!/bin/sh

# $Id: config,v 1.11 2002/03/04 16:45:40 cph Exp $
#
# Copyright (c) 2001, 2002 Massachusetts Institute of Technology
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

set -e

. /usr/share/debconf/confmodule

CONFFILE=/etc/default/tpconfig

db_input medium tpconfig/overwrite-config-file || true
db_go || true

db_get tpconfig/overwrite-config-file || true
if [ "${RET}" = "true" ]; then

    if [ -e ${CONFFILE} ]; then
	# Read the values from the config file and save them in the
	# debconf database.  This preserves them upon reconfiguration
	# or reinstallation.
	. ${CONFFILE} || true
	if [ -n "${RESET_P+foo}" ]; then
	    db_set tpconfig/reset_p "${RESET_P}" || true
	fi
	if [ -n "${OPTIONS+foo}" ]; then
	    db_set tpconfig/options "${OPTIONS}" || true
	fi
    fi

    db_beginblock || true

    db_input medium tpconfig/reset_p || true
    db_go || true

    db_input medium tpconfig/options || true
    db_go || true

    db_endblock || true

fi

# Remove old variables no longer in use.
db_unregister tpconfig/etc-tpconfig-md5 || true
