#!/bin/sh -e
# prompt for configuration settings that are required and have no default

# load the debconf functions
. /usr/share/debconf/confmodule
db_version 2.0

# this conf script is capable of backing up
db_capb backup

STATE=1 
while [ "$STATE" != 0 -a "$STATE" != 6 ]; do
    case "$STATE" in
        1)
            db_input high weewx/location || true
            ;;

        2)
            db_input high weewx/latlon || true
            ;;

        3)
            db_input high weewx/altitude || true
            ;;

        4)
            db_input high weewx/station_type || true
            ;;

        5) # prompt for station-specific parameters
            db_get weewx/station_type
            if [ "$RET" = "Vantage" ]; then
                db_input high weewx/vantage_type || true
                db_go
                db_get weewx/vantage_type
                if [ "$RET" = "serial" ]; then
                    db_input high weewx/vantage_port || true
                else
                    db_input high weewx/vantage_host || true
                fi
            fi

            if [ "$RET" = "WMR-918" ]; then
                db_input high weewx/wmr918_port || true
            fi

            if [ "$RET" = "FineOffsetUSB" ]; then
                db_input high weewx/fousb_model || true
            fi
            ;;
    esac

    if db_go; then
        STATE=$(($STATE + 1))
    else
        STATE=$(($STATE - 1))
    fi
done
