#!/bin/sh

set -e

if [ -x "$(command -v ngcp-virt-identify)" ]; then
	if ngcp-virt-identify --type container; then
		VIRT="yes"
	fi
fi

if [ "$VIRT" = "yes" ]; then
	echo "Container environment detected. Skip daemon"
else
	# make sure it's not running
	if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then
		invoke-rc.d ngcp-rtpengine-daemon stop || true
		rmmod "xt_RTPENGINE" 2>/dev/null || true
	fi
fi

#DEBHELPER#

exit 0
