#!/bin/sh

case $LANG in
    es*)
	MSG1="Informe a quien vaya a descargar el archivo que debe escribir lo siguiente en la barra del navegador:"
	MSG2="Si la otra máquina está en su misma red local deberá pedirle que escriba:"
	;;
    gl*)
	MSG1="Informe a quen vaia a descargar o ficheiro que debe escribir o seguinte na barra do navegador:"
	MSG2="Se a outra máquina está na súa mesma rede local deberá pedirlle que escriba:"
	;;
    *)
	MSG1="Tell the one who is downloading the file to write in the browser as follow:"
	MSG2="If the other computer is in the same local net as yours (LAN) you have to ask it to write:"
	;;
esac

# EN DEBIAN LENNY COMENTAR AS DUAS LIÑAS es*) Y gl*), SÓ USA O VALOR EN INGLÉS 
case $LANG in
#	es*) CORTE="dirección";;
#	gl*) CORTE="enderezo";;
	*) CORTE="addr";;
esac

FIJA=`cat /proc/net/dev | cut -f1 -d: | grep eth`
WIFI1=`cat /proc/net/dev | cut -f1 -d: | grep wlan`
WIFI2=`cat /proc/net/dev | cut -f1 -d: | grep ath`
WIFI3=`cat /proc/net/dev | cut -f1 -d: | grep ra`

AAA=`/sbin/ifconfig $FIJA | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
BBB=`/sbin/ifconfig $WIFI1 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
CCC=`/sbin/ifconfig $WIFI2 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
DDD=`/sbin/ifconfig $WIFI3 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`

if [ $AAA != "" ]; then
	IPLOCAL=$AAA
elif [ $BBB != "" ]; then
	IPLOCAL=$BBB
elif [ $CCC != "" ]; then
	IPLOCAL=$CCC
elif [ $DDD != "" ]; then
	IPLOCAL=$DDD
fi

MYIP=$(wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')

zenity --info --text="$MSG1\n\n<b>http://$MYIP:8000</b>\n\n\n$MSG2\n\n<b>http://$IPLOCAL:8000</b>"

alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'
cd /home/Compartir
webshare
