This file is indexed.

postinst is in ddclient 3.8.1-1ubuntu2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#! /bin/sh

set -e

# -*- sh -*-
# This file can be included with #SCRIPTSCOMMON#

# Fire up debconf and ensure it is at least version 2.0
# Usage: load_debconf2 "$@"  - needed as debconf will exec the current script,
# passing the current shell parameters. So we must lift these into the shell
# function. Missing this caused bug #555151.
load_debconf2() {
   . /usr/share/debconf/confmodule
   if ! db_version 2.0; then
      echo >&2 "$0: need DebConf 2.0 or later"
      exit 1
   fi
}

# Usage: y=`quote_backslashes "$x"`
# Quotes each backslash in $x with another backslash, outputs result.
quote_backslashes() {
  echo -n "$1" | sed 's,\\,\\\\,g'
}

# Usage: hosts=`download_hostlist USER PASSWORD`
# Retrieves the DynDNS hosts of given user
download_hostlist() {
  local username=$1 password=$2
  # FIXME: protect against wget not installed
  wget "http://$username:$password@update.dyndns.com/text/gethostlist" -q -O -\
    | 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_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
  db_go

  # set names using the host list to write it to the config file later
  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
    db_go
  fi
}


case "$1" in
configure)
	
  load_debconf2 "$@"

  if [ ! -f /etc/ddclient.conf ]; then
    # get the values from the debconf database
    db_get ddclient/protocol 		&& protocol="$RET"
    db_get ddclient/server   		&& server="$RET"
    db_get ddclient/names    		&& names="$RET"
    db_get ddclient/username 		&& username="$RET"
    db_get ddclient/password \
      && password=$(echo "$RET"|sed -e "s/'/\\\\'/g")
    db_get ddclient/interface
	if [ "$RET" ]; then
		interface="use=if, if=$RET"
	else
		db_get ddclient/checkip
		if [ "$RET" = "true" ]; then
			interface="use=web, web=checkip.dyndns.com, web-skip='IP Address'"
		fi
	fi

    # create configuration file /etc/ddclient.conf
    config=`mktemp /etc/ddclient.conf.XXXXXX`
    trap "rm -f $config; exit 1" HUP INT QUIT TERM
    password_quoted=`quote_backslashes "$password"`
    cat <<EOF >>"$config"
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

protocol=$protocol
$interface
server=$server
login=$username
password='$password_quoted'
$names
EOF
    mv $config /etc/ddclient.conf


    # create /etc/default/ddclient if it does not exist
    if [ ! -f /etc/default/ddclient ]; then
      db_get ddclient/run_daemon			&& run_daemon="$RET"
      db_get ddclient/daemon_interval		&& daemon_interval="$RET"
      db_get ddclient/run_ipup				&& run_ipup="$RET"
      temp=`mktemp /etc/default/ddclient.XXXXXX`
      trap "rm -f $temp; exit 1" HUP INT QUIT TERM
      cat <<EOF >"$temp"
# Configuration for ddclient scripts 
# generated from debconf on $(date)
#
# /etc/default/ddclient

# Set to "true" if ddclient should be run every time a new ppp connection is 
# established. This might be useful, if you are using dial-on-demand.
run_ipup="$run_ipup"

# Set to "true" if ddclient should run in daemon mode
# If this is changed to true, run_ipup must be set to false.
run_daemon="$run_daemon"

# Set the time interval between the updates of the dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in daemon mode.
daemon_interval="$daemon_interval"
EOF
      mv $temp /etc/default/ddclient
	

    fi
  fi

  db_stop

    ;;


    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

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

# Automatically added by dh_installinit
if [ -x "/etc/init.d/ddclient" ] || [ -e "/etc/init/ddclient.conf" ]; then
	if [ ! -e "/etc/init/ddclient.conf" ]; then
		update-rc.d ddclient start 20 2 3 4 5 . stop 20 1 . >/dev/null
	fi
	invoke-rc.d ddclient start || exit $?
fi
# End automatically added section


exit 0