#!/bin/sh

set -e

case "$1" in
    install|upgrade)
        if dpkg --compare-versions "$2" "<" "4.1.0"; then
            # sync_branch is obsolete
            if [ -f /etc/default/kamailio.lb ]; then
                sed -e 's/RUN_KAMAILIO=yes/RUN_KAMAILIO=no/' -i /etc/default/kamailio.lb
            fi
            if [ -f /etc/default/kamailio.proxy ]; then
                sed -e 's/RUN_KAMAILIO=yes/RUN_KAMAILIO=no/' -i /etc/default/kamailio.proxy
            fi
            echo "kamailio deactivate. Run ngcpcfg apply to reactivate."
        fi
        ;;

    abort-upgrade)
        ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
        ;;
esac

#DEBHELPER#
