#!/bin/sh

. /usr/share/debconf/confmodule

db_version 2.0
db_capb backup

MAX_STATES=4
STATE=1

while [ $STATE  -ne 0 -a $STATE -le $MAX_STATES ]; do
    case "$STATE" in
	1)
	    db_input critical cvs-conf/cvs_create || true
            if db_go ; then
                db_get cvs-conf/cvs_create || true
                if [ ! -z "$RET" ]; then
		    if [ "$RET" = "false" ]; then
		    	STATE=$(($MAX_STATES + 1))
		    else
		    	STATE=$(($STATE + 1))
		    fi
                fi
            else
                STATE=0
            fi
            ;;
        2)
	    db_input critical cvs-conf/cvs_root || true
            if db_go ; then
                db_get cvs-conf/cvs_root || true
                if [ ! -z "$RET" ]; then
		    STATE=$(($STATE + 1))
                fi
            else
                STATE=0
            fi
            ;;
	
	3)  
	    db_input critical cvs-conf/cvs_rsh || true
            if db_go ; then
                db_get cvs-conf/cvs_rsh || true
                if [ ! -z "$RET" ]; then
		    [ "$RET" = "(none)" ] && RET=
		    STATE=$(($STATE + 1))
		fi
            else
                STATE=0
            fi
            ;;
	4)
	    db_input critical cvs-conf/cvs_module || true
	    if db_go ; then
		db_get cvs-conf/cvs_module || true
		if [ ! -z "$RET" ]; then
		    STATE=$(($STATE + 1))
		fi
	    else
		STATE=0
	    fi
	    ;;
	
    esac
done

if [ $STATE -eq 0 ]; then
    exit 1
fi
