#!/bin/sh -e

APP="coremon"

SOLOMON_ROOT="/Berkanavt/solomon"
APP_ROOT="${SOLOMON_ROOT}/${APP}"

case "$1" in
    upgrade)
        /bin/rm -fr ${APP_ROOT}/libs
        ;;

    remove|purge)
        if [ -x /bin/systemctl -a -f /etc/systemd/system/yandex-solomon-${APP}.service ] ; then
            if ! /bin/systemctl stop yandex-solomon-${APP} ; then
                echo "Cannot stop ${APP} service!"
            fi
        elif [ -x /bin/systemctl -a -f /etc/systemd/system/solomon-${APP}.service ] ; then
            if ! /bin/systemctl stop solomon-${APP} ; then
                echo "Cannot stop ${APP} service!"
            fi
        fi

        /bin/rm -fr ${APP_ROOT}/libs
        ;;
esac
