#!/bin/sh -e

# use debconf
. /usr/share/debconf/confmodule

CHECKS=/usr/lib/atokx/patchcheck.pl

if [ ! -x $CHECKS ] || ! $CHECKS; then
    db_fset atokx/have_patches seen false
    db_fset atokx/patches_dir seen false
    db_fset atokx/connect_inet seen false
fi

# title
db_title 'Configuring atokx installer'

db_input high atokx/archive_dir || true
db_input medium atokx/have_patches || true
db_go || true

db_get atokx/have_patches
if [ $RET = true ]; then

    db_input high atokx/patches_dir || true
    db_go || true

else

    db_input medium atokx/connect_inet || true
    db_go || true

    db_get atokx/connect_inet
    if [ $RET = false ]; then
	db_input high atokx/patches_needed || true
	db_go || true
	db_fset atokx/have_patches seen false
	db_fset atokx/connect_inet seen false
	exit 1
    fi

fi

db_input medium atokx/shift_space || true
db_input medium atokx/restart || true
db_go || true
