pre_install() {
	# title			:conky-builder pre installation
	# author		:Glenn Cady <theemahn@ultimateedition.info>
	# date			:03/08/2018
	# ============================================================================

	#Pull info we will use to compare against later
	IUSER=${SUDO_USER:-$USER}
	IHOME="/home/$IUSER"

	# Check inode of rootfs if anything other then 2 we are in a chroot environment
	# use above IUSER results to further our cause.& guarantee our success ;)
	# Inform user of current findings:

	root_inode=$(stat -c %i /);
	if [ -f /etc/xdg/autostart/cbuilder.desktop ] ; then
	    rm /etc/xdg/autostart/cbuilder.desktop
	fi
	if [ -f /usr/lib/systemd/system/conky-builder.service ] ; then
		rm /usr/lib/systemd/system/conky-builder.service
	fi
	exit 0;
}
post_install() {
	# title			:conky-builder post installation
	# author		:Glenn Cady <theemahn@ultimateedition.info>
	# date			:11/05/2013
	# ============================================================================

	#Pull info we will use to compare against later
	IUSER=${SUDO_USER:-$USER}
	IHOME="/home/${IUSER}"

	# Check inode of rootfs if anything other then 2 we are in a chroot environment
	# use above IUSER results to further our cause.& guarantee our success ;)
	# Inform user of current findings:

	root_inode=$(stat -c %i /);
	if [ $root_inode -ne 2 ]; then echo "Chroot environment detected."; else echo "We are NOT in a chroot environment."; fi

}
pre_remove() {
	# title			:conky-builder post installation
	# author		:Glenn Cady <theemahn@ultimateedition.info>
	# date			:11/05/2013
	# ============================================================================

	#Pull info we will use to compare against later
	IUSER=${SUDO_USER:-$USER}
	IHOME="/home/$IUSER"

	# Check inode of rootfs if anything other then 2 we are in a chroot environment
	# use above IUSER results to further our cause.& guarantee our success ;)
	# Inform user of current findings:

	root_inode=$(stat -c %i /);

	if [ $IUSER != 'root' -a $root_inode == 2 ]; then
		echo "Removing Conky Builder for $IUSER."
		if [ -e $IHOME/.config/Ultimate-Player/UP.sh ]; then
			echo 'Removing Ultimate Player script for '$IUSER'.'
			rm $IHOME/.config/Ultimate-Player/UP.sh
		fi
		if [ -e $IHOME"/conky-builder.sh" ]; then
			rm $IHOME/conky-builder.sh
		fi
		if [ -e "$IHOME/.draw_bg.lua" ]; then
			rm $IHOME/.draw_bg.lua
		fi
		echo "Done."
	fi
	if [ $root_inode != 2 -a $IUSER == 'root' ]; then
		echo "Chroot environment as user root detected."
		echo "Removing Conky Builder for $IUSER."
			if [ -e /etc/skel/.config/Ultimate-Player/UP.sh ]; then
				echo 'Removing Ultimate Player script for '$IUSER'.'
				rm -R /etc/skel/.config/Ultimate-Player/
			fi
			if [ -e /etc/skel/conky-builder.sh ]; then
				rm /etc/skel/conky-builder.sh
			fi
			if [ -e /etc/skel/.draw_bg.lua ]; then
				rm /etc/skel/.draw_bg.lua
			fi
		echo "Done."
		fi
	if [ $root_inode == 2 -a $IUSER == 'root' ]; then
		echo 'Removing scripts for root user.'
		if [ -e /root/.config/Ultimate-Player/UP.sh ]; then
			echo 'Removing Ultimate Player script for '$IUSER'.'
			rm /root/.config/Ultimate-Player/UP.sh
		fi
		if [ -e /root/conky-builder.sh ]; then
			rm /root/conky-builder.sh
		fi
		if [ -e "/root/.draw_bg.lua" ]; then
			rm /root/.draw_bg.lua
		fi
		echo "Done."
	fi
	#if [ -d /run/systemd/system ]; then
	#    deb-systemd-invoke stop conky-builder.service >/dev/null
	#	deb-systemd-invoke stop conky.service >/dev/null
	#fi
	#if [ -x "/etc/init.d/conky-builder" ] || [ -e "/etc/init/conky-builder.conf" ]; then
	#    invoke-rc.d conky-builder stop || exit $?
	#	invoke-rc.d conky stop || exit $?
	#fi
}
post_remove() {
	if [ -d /run/systemd/system ]; then
	    systemctl --system daemon-reload >/dev/null || true
	fi
	if [ "$1" = "remove" ]; then
	    if [ -x "/usr/bin/deb-systemd-helper" ]; then
	        deb-systemd-helper mask conky-builder.service >/dev/null
			deb-systemd-helper mask conky.service >/dev/null
	    fi
	fi

	if [ "$1" = "purge" ]; then
	     if [ -x "/usr/bin/deb-systemd-helper" ]; then
	        deb-systemd-helper purge conky-builder.service >/dev/null
	        deb-systemd-helper unmask conky-builder.service >/dev/null
			deb-systemd-helper purge conky.service >/dev/null
	        deb-systemd-helper unmask conky.service >/dev/null
	    fi
	fi
}
