#!/bin/sh -e

. /usr/share/debconf/confmodule

## Disabled this to get an easier installation of standalone machines,
## users could still select no to do manual partitioning (if it works)
manual_standalone=false

template="debian-edu-install/profile"

log() {
    logger -t profilechooser "info: $*"
}

log "choosing profile"

RET=""
looplimit="xxx"
loopcount=""

while test -z "$RET" ; do
    db_fset "$template" seen false || true
    db_input critical "$template"  || [ $? -eq 30 ]
    db_go || true
    db_get "$template" || true
    loopcount="x$loopcount"
    if test "$loopcount" = "$looplimit" ; then
	break;
    fi
done

log "profile = '$RET' loopcount='$loopcount'"

if [ true = "$manual_standalone" ] && echo "$RET" | grep -q Standalone ; then
    # Let standalone installs be less automatic, change priority from
    # high to medium

    # Warn the user first
    db_input critical debian-edu-install/standalone || [ $? -eq 30 ]
    db_go || true

    db_set debconf/priority medium
fi
