dict_update.sh 1.27 KB
#!/bin/bash

echo -e "\n\033[32m##### Atualizando dicionário #####\033[0m\n"

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

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 [ ! -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 

#remove pasta bundles
if [ -d "$BUNDLES" ] ; then
	rm -r $BUNDLES
fi

#copia dicionário para pasta de bundles
cp -r $DIR $PLAYER_DATA
cd $BUNDLES
rm *.description

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