#!/bin/sh
# postinst script for mythtv-status
#
# see: dh_installdeb(1)

PACKAGE=mythtv-status

. /usr/share/debconf/confmodule

set -e

case "$1" in
  configure|reconfigure)
    DEBIANCONFIG=/etc/default/$PACKAGE

    # Default to --email-only-on-alert but allow it be unset in the config file.
    EMAIL_ARGS="---email-only-on-alert"

    # load current settings, most of which will be overwritten.
    [ -f $DEBIANCONFIG ] && . $DEBIANCONFIG

    db_get $PACKAGE/host
    HOST="${RET:-localhost}"

    db_get $PACKAGE/enable
    RUN="${RET:-true}"

    if [ $RUN = 'true' ]
    then
      RUN='yes'
    fi

    db_get $PACKAGE/email
    EMAIL="${RET:-none}"

    cat <<_eof > $DEBIANCONFIG
# $PACKAGE Debian configuration
#
# You can run 'dpkg-reconfigure $PACKAGE' to modify the values in this
# file, if you want. You can also change the values here and changes will
# be preserved.  But other changes will not be preserved.
#
# Do note that only the values are preserved; the rest of the file is
# rewritten.
#

# HOST:
#  What host should we check the status on?
HOST=$HOST

########################################################################
# The following settings are used by /etc/init.d/mythtv-status script  #
# to update the MOTD.                                                  #
########################################################################

# RUN:
#  Should we actually run and update the MOTD?
RUN=$RUN

# ARGS:
#  Any extra arguments to pass to mythtv-status (i.e., -e and/or -d).
ARGS="$ARGS"

########################################################################
# The following settings are used by the /etc/cron.daily/mythtv-status #
# script when generating the daily status email report.                #
########################################################################

# EMAIL:
#  A comma separated list of email address to send status emails to.
#
#  Set to none (or leave empty) to disable daily emails.
EMAIL=$EMAIL

# EMAIL_ARGS:
#  Command line arguments that are used when sending the daily email.
EMAIL_ARGS="$EMAIL_ARGS"
_eof

    db_stop
  ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


