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

VERSION=$(dpkg-query -W -f='${Version}' libreswan-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 libreswan $VERSION /usr/share/libreswan-modules-dkms $ARCH $2

	    if ipsec --version | grep -q '(klips)'; then
		db_get libreswan/restart

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

#DEBHELPER#

