#!/bin/sh -e

case "$1" in
    failed-upgrade|abort-install|abort-upgrade|disappear|upgrade)
    ;;
    purge)
        if [ -f /etc/nginx/conf-enable/50-zabbix.conf ]; then
            rm -f /etc/nginx/conf-enable/50-zabbix.conf
        fi
        if [ -f /etc/nginx/conf-available/50-zabbix.conf ]; then
            rm -f /etc/nginx/conf-available/50-zabbix.conf
        fi

    remove)
        if [ -f /etc/nginx/conf-enable/50-zabbix.conf ]; then
            rm -f /etc/nginx/conf-enable/50-zabbix.conf
        fi

        # process multiple php versions
        for dir in $(realpath /etc/php/*/fpm/pool.d); do
            if [ -e "$dir/zabbix-php-fpm.conf" ]; then
                if [ "$(realpath "$dir/zabbix-php-fpm.conf")" = /etc/zabbix/web/php-fpm.conf ]; then
                    rm "$dir/zabbix-php-fpm.conf"
                fi
            fi
        done
    ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
esac

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

#DEBHELPER#

exit 0
