#!/bin/sh
set -e
test $DEBIAN_SCRIPT_DEBUG && set -v -x

VERSION=$(dpkg-query -W -f='${Version}' openswan-modules-dkms | sed -e 's/.*:\(.*\)/\1/' -e 's/\(.*\)-.*/\1/')
ARCH=`dpkg --print-architecture`

. /usr/share/debconf/confmodule

case "$1" in
    configure)
	if [ -x /usr/lib/dkms/common.postinst ]; then
	    /usr/lib/dkms/common.postinst openswan $VERSION /usr/share/openswan-modules-dkms $ARCH $2

	    if ipsec --versioncode | grep -q '(klips)'; then
		db_get openswan/restart

		if [ "$RET" = "true" ]; then
		    ipsec setup restart || true
		fi
	    fi
	fi
	db_stop
    ;;
esac

#DEBHELPER#

