dict_update.sh 1.2 KB
#!/bin/bash

echo -e "\n\033[32m##### Iniciando a instalação VLibras-Core #####\033[0m\n"

NOT_INSTALLED=false
DIR=/opt/vlibras_desktop/vlibras_player_Data/Bundles
BUNDLES=$HOME/unityVideo/videoCreator_Data

function check_update_patches()
{
    count=0
    for d in "$DIR/*" ; do
        count=$((count+1))
        apt-get install --only-upgrade --force-yes --yes patch${count}.0.0 > /dev/null 2>&1
    done
}

if [ ! -d "$BUNDLES" ] ; then
	mkdir $BUNDLES
fi

if [ ! -f /etc/apt/sources.list.d/dicionario-vlibras.list ]; then
	# Add repository to update the dictionary
	echo 'deb http://150.165.204.46:8080 precise main' | sudo tee /etc/apt/sources.list.d/dicionario-vlibras.list > /dev/null 2>&1
fi

PKG_DICT=$(dpkg-query -W --showformat='${Status}\n' dicionario-vlibras:i386|grep "install ok installed")
if [ "" == "$PKG_DICT" ]; then
	NOT_INSTALLED=true
	sudo apt-get install --force-yes --yes dicionario-vlibras:i386
else
	sudo apt-get update
	check_update_patches
	sudo apt-get install --only-upgrade --force-yes --yes dicionario-vlibras:i386
fi 

#copia dicionário para pasta de bundles
cp -r $DIR $BUNDLES

#remove pacote
if [ "$NOT_INSTALLED" = true ] ; then
    sudo apt-get autoremove -y dicionario-vlibras:i386
fi