From 6ff091a18cfcc144c33b3cdbd1a9373a2f47be4b Mon Sep 17 00:00:00 2001 From: Andrew Pogrebennyk Date: Mon, 25 Aug 2014 11:20:35 +0200 Subject: [PATCH] Revert "MT#8741 remove init script tricks" This reverts commit 8b3a87eeeda3d8c44707806f0c94581e388776df. --- debian/ngcp-sems.postinst | 54 ++++++++++++++++++++++++++++++++++++--- debian/ngcp-sems.postrm | 18 +++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 debian/ngcp-sems.postrm diff --git a/debian/ngcp-sems.postinst b/debian/ngcp-sems.postinst index 73acc76d..443ad147 100644 --- a/debian/ngcp-sems.postinst +++ b/debian/ngcp-sems.postinst @@ -5,11 +5,9 @@ set -e dpkg-maintscript-helper rm_conffile /etc/default/sems -- "$@" dpkg-maintscript-helper rm_conffile /etc/init.d/sems -- "$@" +# don't do anything when called with other argument than configure case "$1" in configure) - # add sems user - adduser --quiet --system --group --disabled-password --shell /bin/false \ - --gecos "SIP Express Media Server" --home /var/run/ngcp-sems sems || true ;; abort-upgrade|abort-remove|abort-deconfigure) exit 0 @@ -20,6 +18,54 @@ case "$1" in ;; esac -#DEBHELPER# +restart_handler() { + if [ -x "/etc/init.d/ngcp-sems" ]; then + if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then + invoke-rc.d ngcp-sems restart || exit $? + else + /etc/init.d/ngcp-sems restart || exit $? + fi + fi +} + +initscript_handler() { + if [ -x "/etc/init.d/ngcp-sems" ]; then + update-rc.d ngcp-sems defaults >/dev/null + invoke-rc.d ngcp-sems start || exit $? + fi +} + +init_handler() { + # just invoke init script wrappers on ce systems since + # they do not provide ngcp-check_active and we don't + # have to handle inactive nodes + if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then + restart_handler + initscript_handler + else # do not restart daemon on inactive node in pro systems + if ngcp-check_active ; then + echo "Active node detected, restarting ngcp-sems" + restart_handler + else + echo "Inactive node detected, ignoring request to restart ngcp-sems" + fi + fi +} + +# add sems user +adduser --quiet --system --group --disabled-password --shell /bin/false \ +--gecos "SIP Express Media Server" --home /var/run/ngcp-sems sems || true + +init_handler + +echo "" +echo "***" +echo "Configuration of ngcp-sems has finished." +echo "" +echo "To restart it when configuration has changed use '/etc/init.d/ngcp-sems restart'" +echo "" +echo "To change it's configuration use 'dpkg-reconfigure ngcp-sems'" +echo "***" +echo "" exit 0 diff --git a/debian/ngcp-sems.postrm b/debian/ngcp-sems.postrm new file mode 100644 index 00000000..29fbd00b --- /dev/null +++ b/debian/ngcp-sems.postrm @@ -0,0 +1,18 @@ +#!/bin/sh +# postrm script for ngcp-sems + +set -e + +removal_wrapper() { + # remove the init script only on ce systems, as the + # the pro system handle it inside the monitoring/HA setup + if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then + update-rc.d ngcp-sems remove >/dev/null + fi +} + +if [ "$1" = "purge" ] ; then + removal_wrapper +fi + +exit 0