#!/bin/sh -e

SOLOMON_ROOT="/Berkanavt/solomon"

APP="slicer"
APP_ROOT="${SOLOMON_ROOT}/${APP}"

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

case "$1" in
    configure)
        /bin/chown ${USER}:${GROUP} ${APP_ROOT}

        if [ -f /etc/systemd/system/yandex-solomon-${APP}.service ] ; then
            if ! /bin/systemctl restart yandex-solomon-${APP} ; then
                echo "Cannot restart ${APP} service!"
            fi
        elif [ -f /etc/systemd/system/solomon-${APP}.service ] ; then
            if ! /bin/systemctl restart solomon-${APP} ; then
                echo "Cannot restart ${APP} service!"
            fi
        fi
    ;;
esac
