Archive for 21 junio 2013

h1

Squid3 error TCP_DENIED/407 (problema autenticación)

21/06/2013

Si en Squid3 instalando el módulo de autenticación básico (NCSA) no loguea correctamente, produciéndose estos errores en el log:

1371588666.720 0 172.26.0.34 TCP_DENIED/407 2259 CONNECT clients2.google.com:443 - NONE/- text/html
1371588667.607 0 172.26.0.34 TCP_DENIED/407 2259 CONNECT clients2.google.com:443 - NONE/- text/html

En necesario otorgar permiso “sticky bit” al módulo de autenticación:

$ sudo chmod u+s /usr/lib/squid3/ncsa_auth

y después reiniciar Squid3:

$ sudo /etc/init.d/squid3 restart

Anuncios
h1

How to create an egg for the GCP in Linux

09/06/2013

Updated: Finnaly a GCP egg can be configured in this link.

These instructions show how to create an egg in a PC with GNU/Linux  for the GCP, although these instructions can be used as clues when creating an egg on Windows, as steps are the same.

First of all, take in consideration that the egg you will creat should be running 24h/365days. For joining at GCP it is necessary a special hardware issued by the GCP manager, so you will have to send an email to phd Roger Nelson with the following information:

1º) Postal address for sending the device, telephone number for eventual problems, GPS location of the future node for placing it at the eggs map.
2º) your IP address, that is, the IP address of the computer that will be hosting the egg. It must be the routable IP, which you can learn by point a browser at the website whatismyip.com , or an URL (like DynDNS).
3) Operating system and hardware you are using to deploy the server.
4) If you wish, you can have a link to your personal website or to an affiliated university or business in the table that shows egg status.

He will answer you with a configuration file to run the egg. After this, lets follow this steps:

0.- Have your server ready. You need any computer with an Internet connection and a port to plug the special hardware.

If you are sent a serial-port device and you are using a Raspberry Pi, just notice it is not compatible with the GCP Orion device (may be with others devices), as the minimun required voltage is 5V, while the Raspberry PI uses 3’3V.

RaspberryPi-Hand

Just for information reasons, I have tried with:

– Raspberry Pi serial port adaptor at DealExtreme.com
– Raspberry Pi serial port adaptor at Miniinthebox.com and male to male adaptor.

rs232_dx_sku_144192_1

So while using a Raspberry Pi PC and an Orion device, a serial-USB adaptor may not be a good idea, as the one i tested didn’t get valid data from the random generator device. With the serial port, plug the GCP device into the Raspberry Pi in this way, but it will not either work as the voltage is not enough.

At this point, just notice i could’nt make Raspberry Pi work with the Orion device. Instructions for a common PC are:

1.- Install the operating system. Debian is a good option as it has the last GCP packages at its repositories.

2.- Set a fixed ip. Later, install the SSH daemon:

$ sudo apt-get install openssh-server

and do a full update of the system:
$ sudo apt-get update
$ sudo apt-get upgrade

finally, reboot:
$ sudo reboot

3.- It is mandatory to sync periodically date and hour. To get this command executed daily, follow this instructions:
$ sudo apt-get install ntpdate
$ sudo sudo cron -e
Add this line:
15 1 * * * /usr/sbin/ntpdate -ud hora.rediris.es
save and exit.

4.- It is necessary to specify to the GCP the public IP you are using (not the LAN one). As in general people have a dynamic one (changed everytime there is a router reboot, power failure or at ISP desire), you can use a trick which will allow to bypass this problem. The idea is to publish your IP in a DNS system, like DynDNS, and tell GPC to listen data from that address (as authentication method). Follow these steps:

4.1 Register an account at DynDNS.org (there are many alternatives on the web, as good as this, and the steps will be so similar).
4.2 Logged in that account, create a subdomain, for example “eggMADRID.ath.cx”
4.3 Download and install a software to update your ip for that subdomain:
$ sudo apt-get install dyndns
4.4 Configure that client with you settings (username, password and subdomain).
4.5 Do a test: reboot your router (for changing the IP), execute the client and ask somebody (from another Internet connection) to ping that subdomain. If the IP matches your new IP), you are done.
4.5 Add the updater command to the cron like in the step 3, so everyday your IP will be sent to the DynDNS servers.

There are tons of help, documentation, feedback, forums, experts and solutions for this point on Internet.

5. Preparing the GCP software. Donwload it here depending of the device you have. If you have a 32bits operating system, you can download the binary or in Debian/Ubuntu/Raspbian, do:

$ sudo apt-get install gcpegg

If you have a Linux 64 bits enviroment, you have to download the sources and overwrite some files with the patch developed by Fernando Lucas, or download this full package, or install at least the 5.1-13 version at Debian/Ubuntu repositories (ensure you have available at least that version):

pi@raspberrypi ~ $ apt-cache show gcpegg
Package: gcpegg
Version: 5.1-13

orion
About the device, the GCP software will look for it at these and only these locations:

  • /dev/ttydNUMBER
  • /dev/term/NUMBER
  • /dev/ttySNUMBER

If you haven’t it on any of these paths, you have two options to make it work:

a) Make a link (recommended)
ln -s /dev/YOUR_DEVICE /dev/ttyS0

b) Modify the source code file (reg_pear.c) so the software will look at the place you want (not recommended).

reg_pear.c: sprintf(ttydev, "/dev/ttyd%d", opts->port);
reg_pear.c: sprintf(ttydev, "/dev/term/%c", 'a' + (opts->port - 1));
reg_pear.c: sprintf(ttydev, "/dev/ttyS%d", opts->port); --> reg_pear.c: sprintf(ttydev, "/dev/YOUR_REAL_DEVICE", opts->port);

Finally, you can use a compiled package or use sources. In the last case, do:
make clean
make

In the software folder, copy the file “.eggrc” (given to you by Roger Nelson), which should be similar to this:

EGG egg.madrid.es 3066 pilar002.ath.cx noosphere PERM 1
BASKET noosphere 64.7.11.43
PROTOCOL 10 10 30 200
REG ORION 0 9600

6.- At your Internet connection (router), open the ports UDP 2510 and UDP 1105, pointing to the internal IP of your CPU running the GCP software (the one set at step 2). There are many tutorials on Internet, specifying your router brand you will get specific information.

7.- For automatic starting the process after each reboot and testing it is running each minute, it is necessary to include these two small scripts, adapting the paths to your settings, or use instead this i have created which may be even more useful as it sends you an automatic email if there are problems. For this, please install “sendemail”:

$ sudo apt-get install sendemail libnet-ssleay-perl libio-socket-ssl-perl libio-socket-inet6-perl

and save this script at the same path than eggsh (adapting your email settings):

#!/bin/sh

if ps aux | grep '/eggsh' | grep -v grep
then
echo Egg is running.
else
echo Starting egg
nohup /home/carlos/egg/eggsh &
/usr/bin/sendemail -f FROM_EMAIL\@gmail.com -t TO_EMAIL\@gmail.com -s smtp.gmail.com:587 -u 'Egg GCP, problem' -m 'GCP egg, process not found' -v -xu CHANGE_FOR_USER -xp CHANGE_FOR_PASSWORD -o tls=yes
fi

It is adviced to test the sendemail command previously in a shell. If you get an error like this:
invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332
check this workaround.

Later, give execution permissions:

$ chmod 755 check_egg.sh eggsh

and add at the root cron the first script:
$ sudo crontab -e
* * * * * /home/carlos/egg/check_egg.sh

8.- Tests: When everything seems to work, reboot the system:
$ sudo reboot

and check everything:
$ ps uax | grep eggsh
$ ping google.es
$ /home/pi/egg/regtest /dev/ttyS0 9600
$ killall -9 eggsh  (after one minute, the eggsh should be automatically the re-started again)

9.- Send an email to Roger Nelson to annouce him your egg is ready and working. He will confirm you if everything is fine at the server side.

gcp.map

TROUBLESHOOTING

If you have problems, first of all check these advices:

1º) Give permissions to your device:
chmod 755 /dev/ttyS0 (or the file that matches your device)

2º) Run eggsh as root.

3º) Check you have a similar output like this:
carlos@shirley:~/egg$ ldd eggsh
linux-vdso.so.1 => (0x00007fffca9cf000)
libncurses.so.5 => /lib/libncurses.so.5 (0x00007fa2481d4000)
libc.so.6 => /lib/libc.so.6 (0x00007fa247e4e000)
libdl.so.2 => /lib/libdl.so.2 (0x00007fa247c49000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa248434000)

4º) Check your .eggprotocolrc:
$ more .eggprotocolrc
if you have something like "PROTOCOL 30 51261 62464 0"
this is wrong, change for: "PROTOCOL 10 10 30 200"

5º) Check you are running the eggsh binary in a directory where exists a configure .eggrc file:
pi@raspberrypi ~/egg $ ls -la
drwxr-xr-x 2 pi pi 4096 Jun 9 19:40 .
drwxr-xr-x 6 pi pi 4096 Jun 8 11:43 ..
-rwx------ 1 pi pi 420 Jun 9 19:42 check_egg
-rw-r--r-- 1 pi pi 108 Jun 9 19:40 .eggprotocolrc
-rw-r--r-- 1 pi pi 125 Jun 5 23:02 .eggrc
-rw-r--r-- 1 pi pi 5 Jun 9 19:40 eggsample.pid
-rwxr-xr-x 1 pi pi 92963 May 31 17:04 eggsh
-rwxr-xr-x 1 pi pi 12071 May 31 17:04 regtest
-rwxrwxrwx 1 pi pi 51 Jun 9 19:40 run_egg.sh
-rwxr-xr-x 1 pi pi 693 May 31 17:04 sample.pppscript

6º) Try to update your system. In Ubuntu/debian it would be:
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ reboot

and start again this tutorial from the beginning.

h1

Error invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332

09/06/2013

Si ejecutando sendEmail ocurre el siguiente error:

pi@raspberrypi ~/egg $ sendemail -f ORIGEN@gmail.com -t DESTINO@gmail.com -s smtp.gmail.com:587 -u "Egg GCP, problema" -m "GCP egg, proceso encontrado muerto" -v -xu ORIGEN -xp CLAVE -o tls=yes
Jun 09 18:57:36 raspberrypi sendemail[6130]: DEBUG => Connecting to smtp.gmail.com:587
Jun 09 18:57:36 raspberrypi sendemail[6130]: DEBUG => My IP address is: 172.26.0.15
Jun 09 18:57:36 raspberrypi sendemail[6130]: SUCCESS => Received: 220 mx.google.com ESMTP k10sm6957405wia.4 - gsmtp
Jun 09 18:57:36 raspberrypi sendemail[6130]: INFO => Sending: EHLO raspberrypi
Jun 09 18:57:36 raspberrypi sendemail[6130]: SUCCESS => Received: 250-mx.google.com at your service, [87.221.224.5], 250-SIZE 35882577, 250-8BITMIME, 250-STARTTLS, 250 ENHANCEDSTATUSCODES
Jun 09 18:57:36 raspberrypi sendemail[6130]: INFO => Sending: STARTTLS
Jun 09 18:57:36 raspberrypi sendemail[6130]: SUCCESS => Received: 220 2.0.0 Ready to start TLS
invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332

Se soluciona cambiando una línea en el fichero SSL.pm . Para ello, editarlo y realizar el siguiente reemplazo:

pi@raspberrypi ~/egg $ sudo nano  ./usr/share/perl5/IO/Socket/SSL.pm

Localizar la siguiente línea:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))$}i

y sustituirla por:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i
 

Fuente: RaspBerry StackExchange

h1

Error /usr/bin/openvt: not found

03/06/2013

If installing a package this error happens:

root@shirley:~# apt-get install gcpegg

Leyendo lista de paquetes... Hecho
Creando árbol de dependencias
Leyendo la información de estado... Hecho
Se instalarán los siguientes paquetes NUEVOS:
gcpegg
0 actualizados, 1 se instalarán, 0 para eliminar y 0 no actualizados.
Necesito descargar 41,0kB de archivos.
Se utilizarán 205kB de espacio de disco adicional después de esta operación.
Des:1 http://es.archive.ubuntu.com/ubuntu/ lucid/universe gcpegg 5.1-10 [41,0kB]
Descargados 41,0kB en 0seg. (88,9kB/s)
Seleccionando el paquete gcpegg previamente no seleccionado.
(Leyendo la base de datos ... 00%
183061 ficheros y directorios instalados actualmente.)
Desempaquetando gcpegg (de .../gcpegg_5.1-10_amd64.deb) ...
Procesando disparadores para ureadahead ...
ureadahead will be reprofiled on next reboot
Procesando disparadores para man-db ...
Configurando gcpegg (5.1-10) ...
Starting GCP EGG software on virtual terminal 8: eggsh/etc/init.d/gcpegg: 45: /usr/bin/openvt: not found
invoke-rc.d: initscript gcpegg, action "start" failed.
dpkg: error al procesar gcpegg (--configure):
el subproceso instalado el script post-installation devolvió el código de salida de error 127
Se encontraron errores al procesar:
gcpegg
E: Sub-process /usr/bin/dpkg returned an error code (1)

It is easy to check than the script is looking for a binary in a wrong path. To get the right path:
root@shirley:~# which openvt
/bin/openvt

SOLUTION
Doing a soft link and reinstalling:
root@shirley:~# ln -s /bin/openvt /usr/bin/openvt

root@shirley:~# apt-get install gcpegg
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias
Leyendo la información de estado... Hecho
gcpegg ya está en su versión más reciente.
0 actualizados, 0 se instalarán, 0 para eliminar y 0 no actualizados.
1 no instalados del todo o eliminados.
Se utilizarán 0B de espacio de disco adicional después de esta operación.
Configurando gcpegg (5.1-10) ...
Starting GCP EGG software on virtual terminal 8: eggsh.

h1

Error curses.h no such file or directory

03/06/2013

Si compilando algún software se produce el siguiente error:
curses.h no such file or directory

Se soluciona instalando las librerías de desarrollo que contienen esa cabecera. En Debian/Ubuntu sería:
sudo apt-get install libncurses5-dev libncursesw5-dev