#!/bin/sh ## debconf config script for ddclient ## ## This script runs before copying the files of the package to the correct ## locations in the system. ## ## It gets the appropriate configuration values and stores them in the debconf ## database. If necessary it asks the user about some needed information. ## ## This file is human readable by using "grep '#' " # set -e fatal() { printf %s\\n "$0: $*" >&2; exit 1; } . /usr/share/debconf/confmodule db_version 2.0 || fatal "need DebConf 2.0 or later" # Usage: hosts=`download_hostlist USER PASSWORD` # Retrieves the DynDNS hosts of given user download_hostlist() { local username="$1" password="$2" db_get ddclient/proxy && proxy=$RET || proxy= # FIXME: protect against wget not installed http_proxy="$proxy" https_proxy="$proxy" wget -q -O - \ "http://$username:$password@update.dyndns.com/text/gethostlist" \ | awk -F \: '{print $2, $4}' | sed -e "N;s/ \n/,/g" | sed -e "s/,/, /g" } # Retrieve the list of DynDNS hosts of the user's account from the DynDNS # server and let the user select which hosts to update. retrieve_dyndns_hostlist() { db_go db_get ddclient/username && username="$RET" db_get ddclient/password && password="$RET" hostslist=`download_hostlist "$username" "$password"` # add the list to our multichoice template, then prompt the user db_subst ddclient/hostslist choices "$hostslist" db_input critical ddclient/hostslist || true # set names using the host list to write it to the config file later db_go db_get ddclient/hostslist hostslist=`echo "$RET" | sed -e "s/, /,/g"` db_set ddclient/names "$hostslist" # if the hostslist was blank, let the user know some possible reasons if [ -z "$hostslist" ]; then db_input high ddclient/blankhostslist || true fi } web_choices() { cat </dev/null; then db_input critical ddclient/fetchhosts || true else db_set ddclient/fetchhosts Manually fi db_go db_get ddclient/fetchhosts if [ "${RET}" = "From list" ]; then retrieve_dyndns_hostlist else db_input critical ddclient/names || true fi db_go } if [ "$1" = "configure" ]; then if [ ! -f /etc/ddclient.conf ]; then create_new_config exit 0 fi exit 0 elif [ "$1" = "reconfigure" ]; then create_new_config rm -f /etc/ddclient.conf /etc/default/ddclient fi