#!/bin/sh -e

SOLOMON_ROOT="/Berkanavt/solomon"

APP="project-manager"
APP_ROOT="${SOLOMON_ROOT}/${APP}"

USER="user_${APP}"
GROUP="group_solomon"

case "$1" in
    configure)
        /bin/chown ${USER}:${GROUP} ${APP_ROOT}
        if [ -x /bin/systemctl -a -f /etc/systemd/system/yandex-solomon-${APP}.service ] ; then
            if ! /bin/systemctl restart yandex-solomon-${APP} ; then
                echo "Cannot restart ${APP} service!"
            fi
        elif [ -x /bin/systemctl -a -f /etc/systemd/system/solomon-${APP}.service ] ; then
            if ! /bin/systemctl restart solomon-${APP} ; then
                echo "Cannot restart ${APP} service!"
            fi
        elif [ -x /usr/bin/service -a -f /etc/init/yandex-solomon-${APP}.conf ] ; then
            if ! /usr/bin/service yandex-solomon-${APP} restart ; then
                echo "Cannot restart ${APP} service!"
            fi
        fi
    ;;
esac
