MT#6485 detect container environment

In order to be able to run NGCP inside a container adding the use
of our ngcp-system-tools helper to check the environment.

Merged changes from templates
pull/11/head
Victor Seva 12 years ago
parent b0c0e396d6
commit 02832db063

2
debian/control vendored

@ -17,6 +17,7 @@ Homepage: http://sipwise.com/
Package: ngcp-rtpengine-daemon Package: ngcp-rtpengine-daemon
Architecture: any Architecture: any
Pre-Depends: ngcp-system-tools
Depends: ${misc:Depends}, Depends: ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Conflicts: ngcp-mediaproxy-ng-daemon Conflicts: ngcp-mediaproxy-ng-daemon
@ -61,6 +62,7 @@ Description: IPtables kernel module for the NGCP media proxy - source.
Package: ngcp-rtpengine-kernel-dkms Package: ngcp-rtpengine-kernel-dkms
Architecture: all Architecture: all
Pre-Depends: ngcp-system-tools
Depends: dkms (>= 1.95), Depends: dkms (>= 1.95),
${misc:Depends} ${misc:Depends}
Conflicts: ngcp-mediaproxy-ng-kernel-dkms Conflicts: ngcp-mediaproxy-ng-kernel-dkms

@ -3,9 +3,10 @@
# Provides: ngcp-rtpengine-daemon # Provides: ngcp-rtpengine-daemon
# Required-Start: $remote_fs $syslog # Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog # Required-Stop: $remote_fs $syslog
# Should-Start: sshd
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: Ngcp Mediaproxy-ng # Short-Description: Ngcp Rtpengine
# Description: Proxy for RTP and other media streams # Description: Proxy for RTP and other media streams
### END INIT INFO ### END INIT INFO
@ -68,12 +69,27 @@ fi
case "$1" in case "$1" in
start) start)
set +e
if [ -x "/usr/sbin/ngcp-check_active" ]; then
/usr/sbin/ngcp-check_active -q
status=$?
case "${status}" in
0|3)
echo "Active node or transition."
;;
*)
echo "Ignored start action in inactive node ($status)"
exit 0
;;
esac
fi
echo -n "Starting $DESC: $NAME" echo -n "Starting $DESC: $NAME"
if [ $TABLE -ge 0 ]; then \ if [ $TABLE -ge 0 ] && ! /usr/sbin/ngcp-virt-identify --type container; then
set +e set +e
modprobe xt_MEDIAPROXY modprobe xt_MEDIAPROXY
echo "del $TABLE" > /proc/mediaproxy/control 2>/dev/null if [ -e /proc/mediaproxy/control ]; then
echo "del $TABLE" > /proc/mediaproxy/control 2>/dev/null
fi
iptables -N mediaproxy 2> /dev/null iptables -N mediaproxy 2> /dev/null
iptables -D INPUT -j mediaproxy 2> /dev/null iptables -D INPUT -j mediaproxy 2> /dev/null
iptables -I INPUT -j mediaproxy iptables -I INPUT -j mediaproxy
@ -97,9 +113,11 @@ case "$1" in
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
return $? return $?
fi fi
if [ $TABLE -ge 0 ]; then \ if [ $TABLE -ge 0 ] && ! /usr/sbin/ngcp-virt-identify --type container; then
set +e set +e
echo "del $TABLE" > /proc/mediaproxy/control 2>/dev/null if [ -e /proc/mediaproxy/control ]; then
echo "del $TABLE" > /proc/mediaproxy/control 2>/dev/null
fi
iptables -D INPUT -j mediaproxy 2> /dev/null iptables -D INPUT -j mediaproxy 2> /dev/null
iptables -D mediaproxy -p udp -j MEDIAPROXY --id $TABLE 2>/dev/null iptables -D mediaproxy -p udp -j MEDIAPROXY --id $TABLE 2>/dev/null
ip6tables -D INPUT -j mediaproxy 2> /dev/null ip6tables -D INPUT -j mediaproxy 2> /dev/null
@ -119,7 +137,20 @@ case "$1" in
return $? return $?
fi fi
rm -f $PIDFILE rm -f $PIDFILE
if [ $TABLE -ge 0 ]; then \ if [ -x "/usr/sbin/ngcp-check_active" ]; then
/usr/sbin/ngcp-check_active -q
status=$?
case "${status}" in
0|3)
echo "Active node or transition."
;;
*)
echo "Ignored start action in inactive node ($status)"
exit 0
;;
esac
fi
if [ $TABLE -ge 0 ] && ! /usr/sbin/ngcp-virt-identify --type container; then
sleep 1 sleep 1
set +e set +e
if [ -e /proc/mediaproxy/control ]; then if [ -e /proc/mediaproxy/control ]; then

@ -6,21 +6,24 @@ package=ngcp-rtpengine-kernel-dkms
name=ngcp-rtpengine name=ngcp-rtpengine
version=`dpkg-query -W -f='${Version}' "$package" \ version=`dpkg-query -W -f='${Version}' "$package" \
|rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"` |rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"`
isadded=`dkms status -m "$name" -v "$version"` if /usr/sbin/ngcp-virt-identify --type container; then
echo "Container environment detected. Skip dkms"
if [ "x${isadded}" = "x" ] ; then else
dkms add -m "$name" -v "$version" isadded=`dkms status -m "$name" -v "$version"`
fi if [ "x${isadded}" = "x" ] ; then
dkms add -m "$name" -v "$version"
if [ "$1" = 'configure' ] ; then fi
dkms build -m "$name" -v "$version" && dkms install -m "$name" -v "$version" || true
if [ "$1" = 'configure' ] ; then
# try to start the daemon dkms build -m "$name" -v "$version" && dkms install -m "$name" -v "$version" || true
if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then
invoke-rc.d ngcp-rtpengine-daemon restart || true # try to start the daemon
fi if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then
invoke-rc.d ngcp-rtpengine-daemon restart || true
fi
fi
fi fi
#DEBHELPER# #DEBHELPER#

@ -13,7 +13,11 @@ if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then
invoke-rc.d ngcp-rtpengine-daemon stop || true invoke-rc.d ngcp-rtpengine-daemon stop || true
fi fi
dkms remove -m "$name" -v "$version" --all || true if /usr/sbin/ngcp-virt-identify --type container; then
echo "Container environment detected. Skip dkms"
else
dkms remove -m "$name" -v "$version" --all || true
fi
#DEBHELPER# #DEBHELPER#

Loading…
Cancel
Save