#!/bin/sh
set -e

move_oldconfig()
{
	if [ -f /etc/mantis/config.php ]
	then
		mv /etc/mantis/config.php /etc/mantis/config.php.dpkg-old
	fi
}

case "$1" in
	upgrade)
		OLD_VERSION="$2"
		if dpkg --compare-versions $OLD_VERSION lt 1.0.6 ; then
			move_oldconfig
			sed -i 's/g_hostname/dbserver/;s/g_db_username/dbuser/;s/g_db_password/dbpass/;s/g_database_name/dbname/' /etc/mantis/config.php.dpkg-old > /etc/mantis/oldconfig.php.dbc
		fi
	;;
esac

#DEBHELPER#
