post_install() {


	USER=ventoy
	HOME_DIR=/var/lib/ventoy
	CACHE_DIR=/var/cache/ventoy

	setup_user() {

		if ! getent passwd "${USER}" >/dev/null; then
			adduser --quiet\
				--system \
				--group \
				--gecos "ventoy" \
				--home "${HOME_DIR}" \
				--no-create-home \
				${USER}
		fi
	}


	ACTION="$1"
	OLD_VERSION="$2"

	if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
		if [ -x "/etc/init.d/ventoy" ]; then
			update-rc.d ventoy-web defaults >/dev/null
			invoke-rc.d ventoy-web start || exit 1
		fi
	fi
	if [ -f /etc/systemd/system/multi-user.target.wants/ventoy-web.service ] ; then
		rm /etc/systemd/system/multi-user.target.wants/ventoy-web.service
	fi
	ln -s /usr/lib/systemd/system/ventoy-web.service /etc/systemd/system/multi-user.target.wants/ventoy-web.service

	#deb-systemd-invoke start ventoy-web

}
pre_remove() {
	if [ -x "/etc/init.d/ventoy-web" ]; then
		invoke-rc.d ventoy-web stop || exit 1
	fi
}
post_remove() {
	case "$1" in
	    purge)
	        rm -f /var/log/ventoy.log*
	        ;;

	    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
	        ;;

	    *)
	        exit 1
	        ;;
	esac

	if [ "$1" = "purge" ] ; then
		update-rc.d ventoy-web remove >/dev/null
	fi


	# In case this system is running systemd, we make systemd reload the unit files
	# to pick up changes.
	if [ -d /run/systemd/system ] ; then
		systemctl --system daemon-reload >/dev/null || true
	fi
	exit 0
}
