How to create an egg for the GCP in Linux


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.


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.


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

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

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
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):


if ps aux | grep '/eggsh' | grep -v grep
echo Egg is running.
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

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.



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.

One comment

  1. […] a first attempt several years ago configuring a GCP node in a Raspberry PI with a random number generator hardware with COM port, I […]

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.

A %d blogueros les gusta esto: