#!/bin/bash
#--------------------
#Testing for correct version
#--------------------

set -e

PACKAGE_VERSION="$(dpkg-parsechangelog -S Version |sed -ne 's/^\(\([0-9]\+\):\)\?\(.*\)-.*/\3/p' )"
ICINGA_VERSION="$(icinga2 --version | head -n1 | sed -e 's/.*version: r\([0-9.]\+\).*$/\1/')"

if [ "$ICINGA_VERSION" = "$PACKAGE_VERSION" ]
then
    echo "OK: $ICINGA_VERSION is equal to $PACKAGE_VERSION"
    exit 0
else
    echo "ERROR: $ICINGA_VERSION is not equal to $PACKAGE_VERSION"
    exit 1
fi
