#!/bin/sh

CONFIGFILE=/etc/default/xymon-client

set -e

. /usr/share/debconf/confmodule

if [ -e $CONFIGFILE ]; then
   . $CONFIGFILE || true
fi

# if there is no value configured, look for debconf answers
if [ -z "$XYMONSERVERS" ] ; then
	db_get xymon-client/XYMONSERVERS
	XYMONSERVERS="$RET"
fi
# still nothing? set a default
if [ -z "$XYMONSERVERS" ] ; then
	XYMONSERVERS="127.0.0.1"
fi
# in any case, store the value in debconf
db_set xymon-client/XYMONSERVERS "$XYMONSERVERS"

if [ -z "$CLIENTHOSTNAME" ] ; then
	db_get xymon-client/CLIENTHOSTNAME
	CLIENTHOSTNAME="$RET"
fi
if [ -z "$CLIENTHOSTNAME" ] ; then
	CLIENTHOSTNAME="`hostname -f 2> /dev/null || hostname`"
fi
db_set xymon-client/CLIENTHOSTNAME "$CLIENTHOSTNAME"

db_input high xymon-client/XYMONSERVERS || true
db_input medium xymon-client/CLIENTHOSTNAME || true
db_go || true

