#!/bin/bash

set -eEu

HAVE_RTPENGINE=false

if iptables -L -v -n 2> /dev/null | grep -qi rtpengine >& /dev/null; then
  HAVE_RTPENGINE=true
fi

if ${HAVE_RTPENGINE}; then
  ngcp-service stop rtpengine
fi

iptables-apply "$@"

if ${HAVE_RTPENGINE}; then
  ngcp-service start rtpengine
fi

