#! /bin/sh # postinst script for ez-ipupdate # # see: dh_installdeb(1) set -e # Load the debconf library . /usr/share/debconf/confmodule # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. case "$1" in configure) # Create the user if it doesn't exist if ! id ez-ipupd 2>/dev/null 1>&2 ; then adduser --system --home /var/cache/ez-ipupdate \ --shell /bin/false --gecos "Dynamic DNS client" \ --disabled-password --disabled-login ez-ipupd fi # Create the default cache file touch /var/cache/ez-ipupdate/default-cache chown ez-ipupd /var/cache/ez-ipupdate/default-cache # Remove spurious cache file from the 3.0.11b8-2 broken package rm -f /var/cache/ez-ipupdate/cache-default # Create the default config file (maybe) db_get ez-ipupdate/service_type if [ "$RET" != "configure manually" ] ; then service="$RET" conf="/etc/ez-ipupdate/default.conf" newconf="$conf.dpkg-new" # Grab answers from debconf db_get ez-ipupdate/ppp ppp="$RET" db_get ez-ipupdate/username username="$RET" db_get ez-ipupdate/password password="$RET" db_get ez-ipupdate/hostname hostname="$RET" db_get ez-ipupdate/interface interface="$RET" echo "#!/usr/sbin/ez-ipupdate -c" > "$newconf" cat >> "$newconf" << EOF ### ### Default ez-ipupdate configuration file - EDIT WITH CARE ### Use \`dpkg-reconfigure ez-ipupdate' to update the debconf-generated lines. ### ### The following lines were generated by debconf service-type=$service EOF db_get ez-ipupdate/server || RET="" if [ -n "$RET" ]; then echo "server=$RET" >> "$newconf" else echo "#server=(default)" >> "$newconf" fi cat >> "$newconf" << EOF user=$username:$password host=$hostname interface=$interface EOF db_get ez-ipupdate/dns_wildcard || RET="false" if [ "$RET" = "true" ]; then echo "wildcard" >> "$newconf" else echo "#wildcard" >> "$newconf" fi db_get ez-ipupdate/dns_mx || RET="" if [ -n "$RET" ]; then echo "mx=$RET" >> "$newconf" else echo "#mx=(none)" >> "$newconf" fi cat >> "$newconf" << EOF run-as-user=ez-ipupd cache-file=/var/cache/ez-ipupdate/default-cache EOF if [ "$ppp" = "true" ]; then echo "#daemon" >> "$newconf" else echo "daemon" >> "$newconf" fi echo >> "$newconf" if grep -q '^### Changes below this' "$conf" >/dev/null 2>&1; then sed -ne '/^### Changes below this/,$p' < "$conf" >> "$newconf" else cat >> "$newconf" << EOF ### Changes below this line will be preserved on upgrades. EOF fi # Fix the file permissions chmod 700 "$newconf" rm -f "$conf" && mv "$newconf" "$conf" # Remove that old file, from broken 3.0.11b8-3 package rm -f "$conf.new" fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. # Automatically added by dh_installinit/12.2.3 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/ez-ipupdate" ]; then update-rc.d ez-ipupdate defaults >/dev/null invoke-rc.d ez-ipupdate start || exit 1 fi fi # End automatically added section # ez-ipupdate is a bit misbehaved. db_stop exit 0