#!/bin/sh set -e . /usr/share/debconf/confmodule MYNAME=resolvconf.postinst report() { echo "${MYNAME}: $*" ; } report_err() { report "Error: $*" >&2 ; } report_info() { report "$*" >&2 ; } standard_run_tmpfs_is_available() { : # Initscripts guarantees that /run is available. } ### BEGIN BLOCK THAT SHOULD BE IDENTICAL TO THAT IN THE PREINST ### standard_run_subdirs_created() { { [ -d /run/resolvconf ] || mkdir -v /run/resolvconf ; } \ && { [ -d /run/resolvconf/interface ] || mkdir -v /run/resolvconf/interface ; } } ### END BLOCK THAT SHOULD BE IDENTICAL TO THAT IN THE PREINST ### # We use dh_installinit with --no-start #DEBHELPER# case "$1" in configure) if [ -L /etc/resolvconf/run ] ; then RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)" fi ### BEGIN BLOCK THAT SHOULD BE IDENTICAL TO THAT IN THE PREINST ### # /etc/resolvconf/run is not a non-canonicalizable symlink. # RUN_CANONICALPATH is the canonical path pointed to by /etc/resolvconf/run. # Attempt migration from old to new standard location if [ -L /etc/resolvconf/run ] ; then # It's a canonicalizable symlink # If it's standard then try to migrate from old to new standard location. [ "$RUN_CANONICALPATH" = "/lib/init/rw/resolvconf" ] \ && standard_run_tmpfs_is_available \ && standard_run_subdirs_created \ && { # /etc/resolvconf/run points to the old-standard location # and new-standard run directories are ready for use. # Switch from the old to the new standard location. { F="$(echo /lib/init/rw/resolvconf/*)" \ && [ "$F" ] \ && [ "$F" != '/lib/init/rw/resolvconf/*' ] \ && cp -a /lib/init/rw/resolvconf/* /run/resolvconf \ && report_info "Migrated resolvconf run-time data from /lib/init/rw/resolvconf to /run/resolvconf" } ln -nsf /run/resolvconf /etc/resolvconf/run } fi ### END BLOCK THAT SHOULD BE IDENTICAL TO THAT IN THE PREINST ### # Link tail to original if appropriate if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then db_get resolvconf/link-tail-to-original if [ "$RET" = "true" ] ; then ln -nsf original /etc/resolvconf/resolv.conf.d/tail else : > /etc/resolvconf/resolv.conf.d/tail fi fi # Linkify /etc/resolv.conf if appropriate db_get resolvconf/linkify-resolvconf if [ "$RET" = "true" ] ; then if [ -f /etc/resolv.conf ] \ && { [ ! -L /etc/resolv.conf ] \ || [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ] } then # Back up original file if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original else cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old fi # Before creating the link, make sure that the original file is # at the target of the link. /sbin/resolvconf will overwrite # this when it does an update, of course. if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf fi # Add the original file to the database so that its contents # are included when resolvconf updates. # Yes, this is an ugly workaround for the problem that there # is no way to obtain nameserver information from interface # configurers after they have done their configuration work. cp -a /etc/resolv.conf /etc/resolvconf/run/interface/original.resolvconf fi # Create the link ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf fi ;; # abort-upgrade) # Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade # ;; # abort-remove) # Don't do anything extra here since we don't deconfigure anything in the prerm on remove # ;; # abort-deconfigure) # Don't do anything extra here since we don't do anything in the prerm on deconfigure # ;; esac db_stop enable_updates() { if [ -x "/etc/init.d/resolvconf" ] ; then if which invoke-rc.d >/dev/null 2>&1 ; then invoke-rc.d resolvconf enable-updates || : else /etc/init.d/resolvconf enable-updates fi fi } case "$1" in configure) dpkg-trigger update-resolvconf ;; triggered) # This runs after we and possibly other packages have been configured for trigger in $2 ; do case "$trigger" in update-resolvconf) if [ -x /sbin/resolvconf ] ; then # Presumably we were just installed enable_updates fi ;; esac done ;; abort-remove) # We disable updates in the prerm on remove. # So, enable them again enable_updates ;; # abort-upgrade) # Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade # ;; # abort-deconfigure) # Don't do anything extra here since we don't do anything in the prerm on deconfigure # ;; esac