#!/bin/sh -e

. /usr/share/debconf/confmodule

db_title BitlBee

db_get bitlbee/serveport
if [ "$RET" = "stillhavetoask" ]; then
	if netstat -ltn | grep ':6667' 2> /dev/null > /dev/null; then
		port=6668;
	else
		port=6667;
	fi
	db_set bitlbee/serveport $port;
fi

if db_input medium bitlbee/serveport; then
	db_go;
fi
