#!/bin/sh

set -e

conffile=/etc/popularity-contest.conf

. /usr/share/debconf/confmodule

if [ -f $conffile ] ; then
       # Make sure the config file have the USEHTTP entry
       if grep -q USEHTTP $conffile; then
           :
       else
           # Make sure existing installations keep using SMTP as
           # before, until the administrator enables HTTP manually.
	   # [pere 2005-07-07]
           echo "USEHTTP=\"no\"" >> $conffile
       fi

       . $conffile
       if [ yes = "$PARTICIPATE" ] ; then
               PARTICIPATE=true
       else
               PARTICIPATE=false
       fi
       db_set popularity-contest/participate "$PARTICIPATE"

       if [ yes = "$USEHTTP" ] ; then
               USEHTTP=true
       else
               USEHTTP=false
       fi
       db_set popularity-contest/use-http "$USEHTTP"
fi

db_input medium popularity-contest/participate || [ $? -eq 30 ]
db_go || true

# Only ask about the method if the user want to participate.
db_get popularity-contest/participate || true
if [ "$RET" = "yes" ] || [ "$RET" = "YES" ] || [ "$RET" = "true" ]; then
    db_input low popularity-contest/use-http || [ $? -eq 30 ]
    db_go || true
fi
