#!/bin/sh

set -e


pre_rm()
{
	SVC="yandex-solomon-backup"

	if [ -x /bin/systemctl -a -f /etc/systemd/system/${SVC}.service ] ; then
		echo "Stopping ${SVC}"
		if ! /bin/systemctl stop ${SVC} ; then
			echo "Cannot stop ${SVC} service!"
		fi
		if ! /bin/systemctl disable ${SVC} ; then
			echo "Cannot disable ${SVC} service!"
		fi
	elif [ -x /usr/bin/service -a -f /etc/init/${SVC}.conf ] ; then
		echo "Stopping ${SVC}"
		if ! /usr/bin/service ${SVC} stop ; then
			echo "Cannot stop ${SVC} service!"
		fi
	fi
	find /Berkanavt/solomon-backup/bin/ -type f -name \*.pyc -delete
}


case "$1" in
	remove|purge)
		pre_rm || true
	;;

	failed-upgrade|upgrade|deconfigure)
	;;

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

exit 0
