#!/bin/sh
#
# Ask the required questions unless the first stage installer already
# asked these questions, and stored the result in
# /etc/debian-edu/config

set -e

# debug=true

pkglibdir=/usr/lib/debian-edu-install

. $pkglibdir/debian-edu-common

init_debconf

#set -x

# Choose profile (Main-Server/Workstation/Thin-Client-Server/Standalone/)
ask_profile() {
    	check_mode=`cat /proc/cmdline | grep -i debian-edu-expert`
	template=debian-edu-install/profile
	if [ -n "$check_mode" ] ; then
		template=debian-edu-install/profile-expert
	fi
	db_input high $template || [ $? -eq 30 ]
	db_go
	db_get $template
	PROFILE="$RET"
}

# Tmp solution until the first stage installer works.
# This part should be removed when we start using debian-installer
if test ! -r /etc/debian-edu/config ; then
    PROFILE=""
    count=0
    while test -z "$PROFILE" -a 3 != "$count"; do
        ask_profile
	count=`expr $count + 1`;
    done

    test -d /etc/debian-edu || mkdir -p /etc/debian-edu
    (
	echo "PROFILE=\"$PROFILE\""
    ) > /etc/debian-edu/config
fi

exit 0
