# Teste do sistema WPS_LPR

clear

echo Iniciando Teste de Sistema WPS_LPR

Dist_Linux="`cat /etc/os-release | grep 'NAME="' | grep -v "PRETTY" | grep -v "CPE"`"
if echo $Dist_Linux | egrep "Ubuntu" ;
	then
		python3.8 /WPSBrasil/lpr-wps/cam_connection.py --video --frame_ocr_rate 30 --wps_topic TESTE > /dev/null 2>&1 &
		
elif  echo $Dist_Linux | egrep "CentOS" ;
	then
		python3 /WPSBrasil/lpr-wps/cam_connection.py --video --frame_ocr_rate 30 --wps_topic TESTE > /dev/null 2>&1 &

else
		echo -e " \033[0;36m Distro Linux - Desconhecida \033[0m"
fi


sleep 20

res="`tail -n 40 /var/log/WPS_Lpr/main_lpr_out.log | grep TESTE -A 3`"

if echo $res | egrep "TESTE" > /dev/null 2>&1
	then
		clear
		echo -e " \033[0;32m Sistema WPS_LPR OK \033[0m"
		echo -e "Placas lidas\n"
		tail -n 40 /var/log/WPS_Lpr/main_lpr_out.log | grep TESTE -A 3
		echo -e "Os arquivos de instalacao serao deletados"
		#sleep 3
		rm -rf /WPSBrasil/lpr-wps.zip
		rm -rf /instalacoes/*.sh /instalacoes/*.zip /instalacoes/*.tgz /instalacoes/ParkingPlus_InstallServer*
		rm -rf /WPSBrasil/lpr-wps/*.txt /WPSBrasil/lpr-wps/*.mp4 /WPSBrasil/lpr-wps/__pycache__
	else
		clear
		echo Sistema WPS_LPR não funcionou
		echo Revisar configuracões
fi

sleep 1

pkill -f video