From 57e560487c2fec9c362f7ce4c6a1ba00d2c191f7 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Tue, 20 Sep 2011 16:27:05 +0000 Subject: [PATCH] postinst: do not restart daemon on inactive node From: Michael Prokop --- debian/ngcp-mediaproxy-ng-daemon.postinst | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/debian/ngcp-mediaproxy-ng-daemon.postinst b/debian/ngcp-mediaproxy-ng-daemon.postinst index 1f6866ca6..be217944b 100644 --- a/debian/ngcp-mediaproxy-ng-daemon.postinst +++ b/debian/ngcp-mediaproxy-ng-daemon.postinst @@ -1,6 +1,43 @@ #!/bin/sh +# postinst script for ngcp-mediaproxy-ng-daemon set -e -#DEBHELPER# +init_wrapper() { + if [ -x "/etc/init.d/ngcp-mediaproxy-ng-daemon" ]; then + if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then + invoke-rc.d ngcp-mediaproxy-ng-daemon start || exit $? + else + /etc/init.d/ngcp-mediaproxy-ng-daemon start || exit $? + fi + fi +} +restart_daemon() { + # ce systems do not provide ngcp-check_active + if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then + return 0 + fi + + # do not restart daemon on inactive node in pro systems + if ngcp-check_active ; then + echo "Active node detected, restarting ngcp-mediaproxy-ng-daemon" + init_wrapper + else + echo "Inactive node detected, ignoring request to restart ngcp-mediaproxy-ng-daemon" + fi +} + +case "$1" in + configure) + restart_daemon + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac