#!/usr/bin/bash
#Comando tomado de https://github.com/albfernandez/clienteafirma-deb-package
#Se aplica sugerencia de https://github.com/gecos-team/autofirma-gecos/pull/3
#
#Arreglo manual a https://github.com/ctt-gob-es/clienteafirma/issues/560
#y otras aplicaciones que aun buscan los certificados en .mozilla
if [ ! -d $HOME/.mozilla ] && [ ! -L  $HOME/.mozilla ] ; then
	if [ -d $HOME/.config/mozilla ] ; then
		ln -nsf $HOME/{.config/mozilla,.mozilla}
	else
		zenity --error --text="No se encontro $HOME/.mozilla o $HOME/.config/mozilla
Inicie firefox almenos una vez antes de ejecutar la aplicación"
		exit 1
	fi
fi
if [ ! -f ~/.config/autofirma ]; then
	if [ "$TERM" = "dumb" ]; then 
		gtk-launch autofirma-certificados
	else
		dnie-configurador
	fi
fi
while ps ux|grep dnie-configurador|grep -v grep ; 
do
	sleep 5s
done
AUTOFIRMA_AVOID_UPDATE_CHECK=true AUTOFIRMA_DO_NOT_SEND_ANALYTICS=true \
java -DdisableSslChecks=true -Djdk.tls.maxHandshakeMessageSize=50000 -jar /usr/share/autofirma/autofirma.jar "$@"
