diff --git a/debian/control b/debian/control index f6aaaed6c..6d5c8123e 100644 --- a/debian/control +++ b/debian/control @@ -17,6 +17,7 @@ Homepage: http://sipwise.com/ Package: ngcp-rtpengine-daemon Architecture: any +Pre-Depends: ngcp-system-tools Depends: ${misc:Depends}, ${shlibs:Depends} Conflicts: ngcp-mediaproxy-ng-daemon @@ -61,6 +62,7 @@ Description: IPtables kernel module for the NGCP media proxy - source. Package: ngcp-rtpengine-kernel-dkms Architecture: all +Pre-Depends: ngcp-system-tools Depends: dkms (>= 1.95), ${misc:Depends} Conflicts: ngcp-mediaproxy-ng-kernel-dkms diff --git a/debian/ngcp-rtpengine-daemon.init b/debian/ngcp-rtpengine-daemon.init index 6b1f865a0..48b4dc5aa 100755 --- a/debian/ngcp-rtpengine-daemon.init +++ b/debian/ngcp-rtpengine-daemon.init @@ -3,9 +3,10 @@ # Provides: ngcp-rtpengine-daemon # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog +# Should-Start: sshd # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Ngcp Mediaproxy-ng +# Short-Description: Ngcp Rtpengine # Description: Proxy for RTP and other media streams ### END INIT INFO @@ -68,12 +69,27 @@ fi case "$1" in 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" - if [ $TABLE -ge 0 ]; then \ + if [ $TABLE -ge 0 ] && ! /usr/sbin/ngcp-virt-identify --type container; then set +e 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 -D INPUT -j mediaproxy 2> /dev/null iptables -I INPUT -j mediaproxy @@ -97,9 +113,11 @@ case "$1" in if [ "$?" -ne 0 ]; then return $? fi - if [ $TABLE -ge 0 ]; then \ + if [ $TABLE -ge 0 ] && ! /usr/sbin/ngcp-virt-identify --type container; then 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 mediaproxy -p udp -j MEDIAPROXY --id $TABLE 2>/dev/null ip6tables -D INPUT -j mediaproxy 2> /dev/null @@ -119,7 +137,20 @@ case "$1" in return $? fi 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 set +e if [ -e /proc/mediaproxy/control ]; then diff --git a/debian/ngcp-rtpengine-kernel-dkms.postinst b/debian/ngcp-rtpengine-kernel-dkms.postinst index 3ff7e8200..021c589d0 100644 --- a/debian/ngcp-rtpengine-kernel-dkms.postinst +++ b/debian/ngcp-rtpengine-kernel-dkms.postinst @@ -6,21 +6,24 @@ package=ngcp-rtpengine-kernel-dkms name=ngcp-rtpengine version=`dpkg-query -W -f='${Version}' "$package" \ - |rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"` - -isadded=`dkms status -m "$name" -v "$version"` - -if [ "x${isadded}" = "x" ] ; then - dkms add -m "$name" -v "$version" -fi - -if [ "$1" = 'configure' ] ; then - dkms build -m "$name" -v "$version" && dkms install -m "$name" -v "$version" || true - - # try to start the daemon - if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then - invoke-rc.d ngcp-rtpengine-daemon restart || true - fi + |rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"` + +if /usr/sbin/ngcp-virt-identify --type container; then + echo "Container environment detected. Skip dkms" +else + isadded=`dkms status -m "$name" -v "$version"` + if [ "x${isadded}" = "x" ] ; then + dkms add -m "$name" -v "$version" + fi + + if [ "$1" = 'configure' ] ; then + dkms build -m "$name" -v "$version" && dkms install -m "$name" -v "$version" || true + + # try to start the daemon + if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then + invoke-rc.d ngcp-rtpengine-daemon restart || true + fi + fi fi #DEBHELPER# diff --git a/debian/ngcp-rtpengine-kernel-dkms.prerm b/debian/ngcp-rtpengine-kernel-dkms.prerm index 71fb01948..130c1b223 100644 --- a/debian/ngcp-rtpengine-kernel-dkms.prerm +++ b/debian/ngcp-rtpengine-kernel-dkms.prerm @@ -13,7 +13,11 @@ if [ -x /etc/init.d/ngcp-rtpengine-daemon ] ; then invoke-rc.d ngcp-rtpengine-daemon stop || true 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#