#! /bin/sh
#set -e

. /usr/share/debconf/confmodule

#Installation Type
db_get mythbuntu/install_type
db_subst mythbuntu/summary INSTALLTYPE "$RET"

#Services
db_get mythbuntu/x11vnc
[ "$RET" = "true" ] && SERVICES="x11vnc"
db_get mythbuntu/openssh-server
[ "$RET" = "true" ] && SERVICES="$SERVICES ssh"
db_get mythbuntu/samba
[ "$RET" = "true" ] && SERVICES="$SERVICES samba"
db_get mythbuntu/nfs-kernel-server
[ "$RET" = "true" ] && SERVICES="$SERVICES nfs"
db_get mythbuntu/mysql-server
[ "$RET" = "true" ] && SERVICES="$SERVICES mythtv"
[ -z "$SERVICES" ] && SERVICES="none"
db_subst mythbuntu/summary SERVICES "$SERVICES"

#Remote & Transmitter
db_get lirc/remote
db_subst mythbuntu/summary REMOTE "$RET"
db_get lirc/transmitter
db_subst mythbuntu/summary TRANSMITTER "$RET"

#Video Driver
db_get mythbuntu/video_driver
db_subst mythbuntu/summary VIDEO_DRIVER "$RET"

#Normal Ubuntu Questions
language_name=
db_get localechooser/languagelist
if [ "$RET" ]; then
        language_name="$(zgrep "^[^:]*:$RET:" \
                /usr/lib/ubiquity/localechooser/languagelist.data.gz | \
                head -n1 | cut -d: -f4)"
fi
db_subst mythbuntu/summary LANGUAGE "$language_name"
if db_get console-setup/variant && [ "$RET" ]; then
    db_subst mythbuntu/summary KEYMAP "$RET"
else
    db_get console-setup/layout
    db_subst mythbuntu/summary KEYMAP "$RET"
fi
db_get passwd/user-fullname
db_subst mythbuntu/summary FULLNAME "$RET"
db_get passwd/username
db_subst mythbuntu/summary USERNAME "$RET"
db_get time/zone # actually continent/city (usually)
db_subst mythbuntu/summary LOCATION "$RET"

db_capb escape
db_get ubiquity/partman-made-changes
if [ "$RET" = true ]; then
    db_metaget partman/confirm Extended_description
else
    db_metaget partman/confirm_nochanges Extended_description
fi
db_subst mythbuntu/summary PARTMAN_CHANGES \
    "$(printf %s "$RET" | debconf-escape -e)"
db_capb

db_input high mythbuntu/summary || true
db_go

exit 0
