|
|
|
|
@ -8,30 +8,51 @@ HOMEDIR=/var/run/kamailio
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# summary of how this script can be called:
|
|
|
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
|
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
|
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
|
|
|
# <new-version>
|
|
|
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
|
|
|
# <failed-install-package> <version> `removing'
|
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
|
# the debian-policy package
|
|
|
|
|
#
|
|
|
|
|
# quoting from the policy:
|
|
|
|
|
# Any necessary prompting should almost always be confined to the
|
|
|
|
|
# post-installation script, and should be protected with a conditional
|
|
|
|
|
# so that unnecessary prompting doesn't happen if a package's
|
|
|
|
|
# installation fails and the `postinst' is called with `abort-upgrade',
|
|
|
|
|
# `abort-remove' or `abort-deconfigure'.
|
|
|
|
|
restart_handler() {
|
|
|
|
|
[ -n "$1" ] || return 1
|
|
|
|
|
|
|
|
|
|
if [ -x "/etc/init.d/$1" ]; then
|
|
|
|
|
if [ -x "$(which invoke-rc.d 2>/dev/null)" ]; then
|
|
|
|
|
invoke-rc.d "$1" restart || exit $?
|
|
|
|
|
else
|
|
|
|
|
/etc/init.d/"$1" restart || exit $?
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initscript_handler() {
|
|
|
|
|
[ -n "$1" ] || return 1
|
|
|
|
|
|
|
|
|
|
if [ -x "/etc/init.d/$1" ]; then
|
|
|
|
|
update-rc.d "$1" defaults >/dev/null
|
|
|
|
|
invoke-rc.d "$1" 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 "$1"
|
|
|
|
|
initscript_handler "$1"
|
|
|
|
|
else # do not restart daemon on inactive node in pro systems
|
|
|
|
|
if ngcp-check_active ; then
|
|
|
|
|
echo "Active node detected, restarting $1"
|
|
|
|
|
restart_handler "$1"
|
|
|
|
|
else
|
|
|
|
|
echo "Inactive node detected, ignoring request to restart $1"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
configure)
|
|
|
|
|
adduser --quiet --system --group --disabled-password \
|
|
|
|
|
--shell /bin/false --gecos "Kamailio" \
|
|
|
|
|
--home $HOMEDIR kamailio || true
|
|
|
|
|
|
|
|
|
|
init_handler kamailio-lb
|
|
|
|
|
init_handler kamailio-proxy
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
|
|