-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrtpengine-stop-post
executable file
·39 lines (29 loc) · 1 KB
/
rtpengine-stop-post
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /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 [ -e /proc/rtpengine/control ]; then
echo "del $TABLE" > /proc/rtpengine/control 2>/dev/null
fi
iptables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
iptables -D INPUT -j rtpengine 2> /dev/null
iptables -D rtpengine 2> /dev/null
# The same for ip6tables rules
ip6tables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
ip6tables -D INPUT -j rtpengine 2> /dev/null
ip6tables -D rtpengine 2> /dev/null
rmmod xt_RTPENGINE 2>/dev/null
exit 0