#!/bin/sh -e
#
# Summary of how this script can be called:
#
#  * <postinst> `configure' <most-recently-configured-version>
#  * <old-postinst> `abort-upgrade' <new version>
#  * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#    <new-version>
#  * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#    <failed-install-package> <version> `removing'
#    <conflicting-package> <version>

set -e

case "$1" in
configure)
    . /usr/share/debconf/confmodule
    db_version 2.0

    db_get openafs-fileserver/thiscell
    echo $RET >/etc/openafs/server/ThisCell

    if [ -f /etc/openafs/server/CellServDB ] ; then
        :
    else
        sed -n "/^>$RET/,/^>/p" /etc/openafs/CellServDB | sed '$d' \
            >/etc/openafs/server/CellServDB
        if [ ! -s /etc/openafs/server/CellServDB ] ; then
            echo ">$RET" >/etc/openafs/server/CellServDB
        fi
    fi
    if [ "x$2" != "x" ] ; then
        if dpkg --compare-versions $2 lt 1.2.0-1 ; then
            mv /etc/openafs/server-local/BosConfig \
                /etc/openafs/BosConfig || true
            mv /etc/openafs/server-local/sysid /var/lib/openafs || true
        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.
#DEBHELPER#

exit 0
