#!/bin/bash

cntlpath="/etc/control"

if [ -f $cntlpath ]; then

oldversion=`grep '^Version' /etc/control | awk '/^Version/{print $2}'`

newversion=2.0.0.070

echo "$oldversion  $newversion"

if [[ "$oldversion" > "$newversion" ]]
then
	/usr/share/QuickController/qcp_install_dialog newversion 2>/dev/null
        echo "This latest version has been installed"
	exit 1
else

    	/usr/share/QuickController/qcp_install_dialog oldversion 2>/dev/null
    	echo "There is an old version installed."
	ANS=`awk '/^replace/{print $2}' /tmp/qcp_version`
	if [[ ${ANS} = "1" ]]; then
		echo "You choose to re-install the Quick Controller"
		exit 0
	else	
		echo "You quit the installation"
		exit 1
	fi
fi

fi

exit 0
