#! /bin/sh
# config script for opsi4ucs
#
# see: dh_installdeb(1)

set -e

. /usr/share/debconf/confmodule

db_title "Opsi4UCS"

valid=false
while ! $valid ; do
	db_input high opsi/pcpatch_password1 || true
	db_input high opsi/pcpatch_password2 || true
	db_go || true
	db_get opsi/pcpatch_password1
	password="$RET"
	db_get opsi/pcpatch_password2
	confirm="$RET"
	if [ "$password" = "" -o "$password" != "$confirm" ] ; then
		db_fset opsi/pcpatch_password1 seen false
		db_fset opsi/pcpatch_password2 seen false
		db_input critical opsi/password_mismatch || true
		db_go || true
	else
		valid=true
	fi
done
SERVER_ROLE=`univention-baseconfig get server/role`
if [ "$SERVER_ROLE" != "domaincontroller_master" ]; then
	db_input critical opsi/opsi4ucs_bindpw || true
	db_go || true
fi

db_stop || true

