#!/bin/bash

set -e

CONFFILE=/etc/wb-mqtt-adc.conf

rm -f /var/lib/wb-mqtt-confed/schemas/wb-mqtt-adc.schema.json

if [ "$1" = "purge" ]; then
    ucf  --purge /etc/wb-mqtt-adc.conf
    rm -f /var/lib/wb-mqtt-adc/conf.d/*
    rm -f /etc/wb-mqtt-adc.conf
    rm -f /etc/wb-homa-adc.conf
fi

if [ -f /usr/share/wb-mqtt-adc/wb-homa-adc.conf.old ]; then
    rm -f /etc/wb-homa-adc.conf
    cp -f /usr/share/wb-mqtt-adc/wb-homa-adc.conf.old /etc/wb-homa-adc.conf
    rm -f /usr/share/wb-mqtt-adc/wb-homa-adc.conf.old
    rmdir --ignore-fail-on-non-empty /usr/share/wb-mqtt-adc
fi

# Automatically added by dh_systemd_start/13.3.4
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section


if [ "$1" = "remove" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge wb-mqtt-adc.service >/dev/null
	fi
fi