mirror of https://github.com/sipwise/rtpengine.git
While still not the ideal implementation, this is certainly better than the sysvinit script wrapper. We then will "only" need to move the setup scripts into proper service files later on. Change-Id: I990d6847117a4b91a8365a5e307fd96cf5b1899fchanges/58/20558/6
parent
6fa712d0d8
commit
79807a9c2e
@ -1,2 +1,3 @@
|
||||
daemon/rtpengine /usr/sbin/
|
||||
debian/ngcp-rtpengine-iptables-setup /usr/sbin
|
||||
etc/rtpengine.sample.conf /etc/rtpengine/
|
||||
|
@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
TABLE=0
|
||||
MODNAME=xt_RTPENGINE
|
||||
MANAGE_IPTABLES=yes
|
||||
|
||||
DEFAULTS=/etc/default/ngcp-rtpengine-daemon
|
||||
|
||||
# Load startup options if available
|
||||
if [ -f "$DEFAULTS" ]; then
|
||||
. "$DEFAULTS" || true
|
||||
fi
|
||||
|
||||
MODPROBE_OPTIONS=""
|
||||
|
||||
# Handle requested setuid/setgid.
|
||||
if ! test -z "$SET_USER"; then
|
||||
PUID=$(id -u "$SET_USER" 2> /dev/null)
|
||||
test -z "$PUID" || MODPROBE_OPTIONS="$MODPROBE_OPTIONS proc_uid=$PUID"
|
||||
if test -z "$SET_GROUP"; then
|
||||
PGID=$(id -g "$SET_USER" 2> /dev/null)
|
||||
test -z "$PGID" || MODPROBE_OPTIONS="$MODPROBE_OPTIONS proc_gid=$PGID"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! test -z "$SET_GROUP"; then
|
||||
PGID=$(grep "^$SET_GROUP:" /etc/group | cut -d: -f3 2> /dev/null)
|
||||
test -z "$PGID" || MODPROBE_OPTIONS="$MODPROBE_OPTIONS proc_gid=$PGID"
|
||||
fi
|
||||
|
||||
###
|
||||
|
||||
if [ -x /usr/sbin/ngcp-virt-identify ]; then
|
||||
if /usr/sbin/ngcp-virt-identify --type container; then
|
||||
VIRT="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
firewall_setup()
|
||||
{
|
||||
if [ "$TABLE" -lt 0 ] || [ "$VIRT" = "yes" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$MANAGE_IPTABLES" != "yes" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
modprobe $MODNAME $MODPROBE_OPTIONS
|
||||
|
||||
iptables -N rtpengine 2>/dev/null
|
||||
iptables -D INPUT -j rtpengine 2>/dev/null
|
||||
iptables -I INPUT -j rtpengine
|
||||
iptables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
|
||||
iptables -I rtpengine -p udp -j RTPENGINE --id "$TABLE"
|
||||
ip6tables -N rtpengine 2>/dev/null
|
||||
ip6tables -D INPUT -j rtpengine 2>/dev/null
|
||||
ip6tables -I INPUT -j rtpengine
|
||||
ip6tables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
|
||||
ip6tables -I rtpengine -p udp -j RTPENGINE --id "$TABLE"
|
||||
}
|
||||
|
||||
firewall_teardown()
|
||||
{
|
||||
if [ "$TABLE" -lt 0 ] || [ "$VIRT" = "yes" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# XXX: Wait a bit to make sure the daemon has been stopped.
|
||||
sleep 1
|
||||
|
||||
if [ -e /proc/rtpengine/control ]; then
|
||||
echo "del $TABLE" >/proc/rtpengine/control 2>/dev/null
|
||||
fi
|
||||
|
||||
if [ "$MANAGE_IPTABLES" != "yes" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
iptables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
|
||||
ip6tables -D rtpengine -p udp -j RTPENGINE --id "$TABLE" 2>/dev/null
|
||||
rmmod $MODNAME 2>/dev/null
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
firewall_setup
|
||||
;;
|
||||
stop)
|
||||
firewall_teardown
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -1,2 +1,3 @@
|
||||
etc/rtpengine-recording.sample.conf /etc/rtpengine/
|
||||
recording-daemon/rtpengine-recording /usr/sbin/
|
||||
debian/ngcp-rtpengine-recording-nfs-setup /usr/sbin/
|
||||
|
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DEFAULTS=/etc/default/ngcp-rtpengine-recording-daemon
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Load startup options if available
|
||||
if [ -f "$DEFAULTS" ]; then
|
||||
. "$DEFAULTS" || true
|
||||
fi
|
||||
|
||||
[ -z "$NFS_OPTIONS" ] && NFS_OPTIONS="hard,tcp,intr"
|
||||
|
||||
###
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ "$MUST_NFS" = yes ]; then
|
||||
if ! grep -E -q "^[^ :]+:[^ :]+ $NFS_LOCAL_MOUNT nfs.? " /proc/mounts; then
|
||||
log_action_msg "Mounting NFS share"
|
||||
test -d "$NFS_LOCAL_MOUNT" || mkdir -p "$NFS_LOCAL_MOUNT"
|
||||
mount -t nfs -o "$NFS_OPTIONS" "$NFS_HOST:$NFS_REMOTE_PATH" "$NFS_LOCAL_MOUNT"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
Loading…
Reference in new issue