Browse Source

daemon maintainer scripts: install init script + handle package removal/upgrade

This is supposed to fix the missing ngcp-mediaproxy-ng-daemon
link in /etc/rc2.d on CE systems.

While at it also try to handle restart/stop of service during
upgrades and package removals in a sane way. Needs extensive
testing though.

From: Michael Prokop <mprokop@sipwise.com>
git.mgm/mediaproxy-ng/2.0
Michael Prokop 14 years ago
parent
commit
3e792a689c
3 changed files with 67 additions and 7 deletions
  1. +16
    -7
      debian/ngcp-mediaproxy-ng-daemon.postinst
  2. +18
    -0
      debian/ngcp-mediaproxy-ng-daemon.postrm
  3. +33
    -0
      debian/ngcp-mediaproxy-ng-daemon.prerm

+ 16
- 7
debian/ngcp-mediaproxy-ng-daemon.postinst View File

@ -3,8 +3,7 @@
set -e set -e
# DEBHELPER like wrapper
init_wrapper() {
restart_handler() {
if [ -x "/etc/init.d/ngcp-mediaproxy-ng-daemon" ]; then if [ -x "/etc/init.d/ngcp-mediaproxy-ng-daemon" ]; then
if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then
invoke-rc.d ngcp-mediaproxy-ng-daemon restart || exit $? invoke-rc.d ngcp-mediaproxy-ng-daemon restart || exit $?
@ -14,16 +13,24 @@ init_wrapper() {
fi fi
} }
restart_daemon() {
# just invoke init script wrapper on ce systems since
initscript_handler() {
if [ -x "/etc/init.d/ngcp-mediaproxy-ng-daemon" ]; then
update-rc.d ngcp-mediaproxy-ng-daemon defaults >/dev/null
invoke-rc.d ngcp-mediaproxy-ng-daemon 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 # they do not provide ngcp-check_active and we don't
# have to handle inactive nodes # have to handle inactive nodes
if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then
init_wrapper
restart_handler
initscript_handler
else # do not restart daemon on inactive node in pro systems else # do not restart daemon on inactive node in pro systems
if ngcp-check_active ; then if ngcp-check_active ; then
echo "Active node detected, restarting ngcp-mediaproxy-ng-daemon" echo "Active node detected, restarting ngcp-mediaproxy-ng-daemon"
init_wrapper
restart_handler
else else
echo "Inactive node detected, ignoring request to restart ngcp-mediaproxy-ng-daemon" echo "Inactive node detected, ignoring request to restart ngcp-mediaproxy-ng-daemon"
fi fi
@ -32,7 +39,7 @@ restart_daemon() {
case "$1" in case "$1" in
configure) configure)
restart_daemon
init_handler
;; ;;
abort-upgrade|abort-remove|abort-deconfigure) abort-upgrade|abort-remove|abort-deconfigure)
@ -43,3 +50,5 @@ case "$1" in
exit 1 exit 1
;; ;;
esac esac
exit 0

+ 18
- 0
debian/ngcp-mediaproxy-ng-daemon.postrm View File

@ -0,0 +1,18 @@
#!/bin/sh
# postrm script for ngcp-mediaproxy-ng-daemon
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-mediaproxy-ng-daemon remove >/dev/null
fi
}
if [ "$1" = "purge" ] ; then
removal_wrapper
fi
exit 0

+ 33
- 0
debian/ngcp-mediaproxy-ng-daemon.prerm View File

@ -0,0 +1,33 @@
#!/bin/sh
# prerm script for ngcp-mediaproxy-ng-daemon
set -e
stop_handler() {
if [ -x "/etc/init.d/ngcp-mediaproxy-ng-daemon" ]; then
invoke-rc.d ngcp-mediaproxy-ng-daemon stop || exit $?
fi
}
stop_daemon() {
# just stop the service on ce systems because
# the pro system handle it as part of their monitoring/HA setup
if ! [ -x "$(which ngcp-check_active 2>/dev/null)" ]; then
stop_handler
else
case "$2" in
upgrade)
echo "Detected upgrade procedure, not stopping ngcp-mediaproxy-ng-daemon service."
;;
remove|purge)
stop_handler
;;
esac
fi
}
if [ "$1" = "prerm" ] ; then
stop_daemon
fi
exit 0

Loading…
Cancel
Save