#!/bin/bash
# postinst script for yandex-so-yasmagent
#
# see: dh_installdeb(1)

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>
#        * <postinst> `abort-remove'
#        * <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

if [ "$1" == "configure" ]; then
    cp -f /opt/yandex-so-yasmagent/so-yasmagent.sysconfig /etc/default/yasmagent
    IS_LOGSTORE=$(hostname | grep logstore | wc -l)
    if [ "$IS_LOGSTORE" -gt "0" ]; then
        mv /usr/local/yasmagent/core/modules/so/compllog.py /usr/local/yasmagent/core/modules/so/compllog.py.old-so-yasmagent 2>/dev/null
        cp -f /opt/yandex-so-yasmagent/compllog.py /usr/local/yasmagent/core/modules/so/compllog.py
        cp -f /opt/yandex-so-yasmagent/so-yasmagent-compllog.sysconfig /etc/default/
    fi
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
