#!/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

# Load debconf values
db_version 2.0
db_get hesiod/rhs
rhs="$RET"
db_get hesiod/lhs
lhs="$RET"
db_get hesiod/classes
classes="$RET"

hesconf=/etc/hesiod.conf

createhesconf() {
    cat <<EOF > "$hesconf"
# This file determines the behavior of the Hesiod library.

# This line should pretty much always be the same, unless you have a
# funny environment.
lhs=$lhs

# This determines the Hesiod domain.  You must specify an rhs line.
rhs=$rhs

# This line specifies the class search order.  You can reverse the
# order or leave out IN or HS if you want.  Don't add spaces after the
# beginning of the value.
classes=$classes
EOF
}

edithesconf() {
    sed -e "s/^lhs=.*/lhs=$lhs/" \
	-e "s/^rhs=.*/rhs=$rhs/" \
	-e "s/^classes=.*/classes=$classes/" \
	-i "$hesconf"
}

case "$1" in
    configure)
	if [ ! -f "$hesconf" ]; then
	    createhesconf
	else
	    edithesconf
	fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# Automatically added by dh_makeshlibs
if [ "$1" = "configure" ]; then
	ldconfig
fi
# End automatically added section


exit 0
