#!/bin/bash

ACROREAD_PATH_DIR="/tmp/acroread"
ACROREAD_PATH="/tmp/acroread/AdbeRdr9.5.1-1_i386linux_enu.deb"

ACTION="$1"

case $ACTION in

	preInstall)
			echo "Launching installation wizard...installing dependences:"
			dpkg --add-architecture i386
			apt update
			for Item in "libxml2:i386" "libcanberra-gtk-module:i386" "gtk2-engines-murrine:i386" "libatk-adaptor:i386" "libgdk-pixbuf-xlib-2.0-0:i386" "libnss-sss:i386"; do
				apt install -y $Item
				TEST=$( dpkg-query -s $Item 2> /dev/null| grep Status | cut -d " " -f 4 )
				if [ "$TEST" != 'installed' ];then
					echo "Problem to install: $Item"
					echo "Contact with LinuX Team to solve this problem, www.lliurex.net"
					exit 1
				fi
			done

	;;
	postInstall)
			echo "Intalling MsOfficefonts in adobe reader....please wait"
			LANG=C LANGUAGE=en DEBIAN_FRONTEND=kde apt install -y ttf-mscorefonts-installer
			if [ -d /usr/share/fonts/truetype/msttcorefonts ];then
				cp /usr/share/fonts/truetype/msttcorefonts/* /opt/Adobe/Reader9/Resource/Font/
			fi
	;;
	remove)

		apt-get remove -y adobereader-enu
		TEST=$( dpkg-query -s  adobereader-enu 2> /dev/null| grep Status | cut -d " " -f 4 )
		if [ "$TEST" == 'installed' ];then
			exit 1
		fi
	;;	
esac
exit 0
