#!/bin/bash

set -e

case "$1" in
    configure)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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

#DEBHELPER#

# must follow after dh_environment code
if [ "$1" = "configure" ]; then
    if [ ! -L /etc/xscript-multiple/yandex-team/xscript.conf ]; then
        rm -f /etc/xscript-multiple/yandex-team/xscript.conf
    fi
    chown -R www-data:www-data /var/log/xscript-multiple /var/cache/xscript-multiple
    ln -s -f -T /etc/xscript-multiple/conf-available/yandex-team /etc/xscript-multiple/conf-enabled/yandex-team
    if [ -x "/etc/init.d/xscript-multiple" ]; then
        if [ -x "`which invoke-rc.d >/dev/null 2>&1`" ]; then
            invoke-rc.d xscript-multiple restart yandex-team
        else
            /etc/init.d/xscript-multiple restart yandex-team
        fi
    fi
fi

exit 0
