#! /bin/sh # After systemd send kill signal to the rtpengine daemon, # Wait 5 sec, then clean the iptables stuffs: # 1- delete the forwarding table, # 2- delete the iptables rules related to rtpengine # 3- Unload the kernel module xt_RTPENGINE sleep 5 # Load the Table ID and delete the file that contains this ID rtpengineTable="/etc/default/rtpengine-table" . $rtpengineTable rm -rf $rtpengineTable # Check if the kernel module is loaded MODEXIST=`/sbin/lsmod | grep "xt_RTPENGINE"` if [ -z "$MODEXIST" ]; then exit 0 fi # Delete the Table if [ "$TABLE" -ge 0 ] && [ "$VIRT" != "yes" ]; then set +e if [ -e /proc/mediaproxy/control ]; then echo "del $TABLE" > /proc/mediaproxy/control 2>/dev/null fi if [ -e /proc/rtpengine/control ]; then echo "del $TABLE" > /proc/rtpengine/control 2>/dev/null fi iptables -D INPUT -j mediaproxy 2> /dev/null iptables -F mediaproxy 2> /dev/null iptables -X mediaproxy 2> /dev/null ip6tables -D INPUT -j mediaproxy 2> /dev/null ip6tables -F mediaproxy 2> /dev/null ip6tables -X mediaproxy 2> /dev/null iptables -D INPUT -j mediaproxy 2> /dev/null iptables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null ip6tables -D INPUT -j mediaproxy 2> /dev/null ip6tables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null rmmod xt_MEDIAPROXY 2>/dev/null rmmod xt_RTPENGINE 2>/dev/null set -e fi exit 0