oriolrius.cat

Des del 2000 compartiendo sobre…

Category: Technology

El meu 2015

Reading time: 8 – 12 minutes

Re-editant l’article que vaig escriure per tancar l’any passat aquest any també he volgut fer un resum del que ha donat de si el 2015. Per desgràcia els compromisos personals i familiars no m’han permès publicar-lo fins a principis del 2016, tot i que jo sóc dels que pensa que més val tard que mai. He tancat un nou any on he fet més coses de les que hem pensava i quan m’he posat a rellegir les meves notes diaries, setmanals, mensuals, semestrals i anuals he al·lucinat.

A nivell personal i familiar, de nou he tingut moltíssimes oportunitats pel creixement personal. Moltíssimes ocasions on m’he hagut de sobreposar per aixecar-me i tornar a creixer un cop rera d’un altre. La millor notícia de l’any és que estem esperant el Roc. El que ha de ser el germà del Pol i que ha de neixer durant el mes de Febrer. Aquesta boníssima notícia eclipsa qualsevol altre tema i ha fet de pal de paller al voltant del qual s’han desenvolupat moltíssimes decisions durant l’any.

L’any 2015 va començar amb una bona notícia el mes de febrer perquè tornavem a estar embarassats. Però a finals de març un avortament ens va fer tornar a canviar els plans i la il·lusió es va tornar a esvaïr. Per tal de trencar una mica amb aquest amarg event ens varem escapar durant una setmaneta cap a terres del sur. Varem visitar “Puerto Banús” (Marbella), Puerto de la Duquesa, Tarifa i Gibraltar. Després d’haver passat per la història del Pol això no era res, però de nou apel·lava a la nostre fortalesa emocional. En moments com aquest és quan hem sento infinitament orgullós d’estar amb una persona tan excepcional com l’Estefania. No només ens varem aixecar sinó que ara com ús dic estem apunt de donar la benvinguda al germanet del Pol, en Roc.

Per aquestes mateixes dates la meva avia de Sant Sadurní, la Carmeta, també ens va dir adéu. Era l’últim avi que hem quedava viu. Per desgràcia ja feia una colla de mesos que anava perdent la serenitat. Per si no fos poc la meva mare i el meu germà també durant els primers 5 mesos de l’any van haver de superar temes de salut rellevants. Per sort, en ambdós casos només van ser ensurts. Curiosament per aquestes dates és sempre quan es concentren esdeveniments emocionalment més importants per la família. Coincidint a més amb l’aniversari de la mort del meu pare, la història del Pol, els 12 anys del meu accident de cotxe, el tercer aniversari del nostre casament i la cel·lebració dels meus 38 anys.

També per aquestes dates varem fer una nova escapada amb els “cunyis” (Sarai i Àlex); aquest cop a la costa brava. Concretament a Calella de Palafrugell. Un d’aquests racons que per molts cops que visitis mai et canses de tornar a visitar. No ens oblidem tampoc la caminada que varem fer l’Estefania i jo per celebrar el seu aniversari, junt amb la romeria de Torrelavit, l’Anna i el Carles ens varem arribar fins a Montserrat a peu. Tot un desafiament per nosaltres.

Per desgràcia aquest any no he pogut disfrutar tan del tennis com és habitual en mi els últims anys. Una epicondilitis m’ha tingut uns quatre mesos patint sense poder disfrutar d’aquest esport que tan m’agrada. Per sort he pogut seguir amb l’spinning i també he començat a anar a la pisicina. A finals d’any degut a compromisos professionals i també els personals que ja coneixeu he hagut de deixar l’spinning aprofitant que ja podia tornar a jugar a tennis. Així doncs, s’ha acabat l’any amb alguns quilets extres que cauran ben aviat a la que reprengui la meva activitat esportiva i professional.

De nou hem continuat invertint en la casa, no tan fort com l’any passat perquè ens haviem de recuperar una miqueta però si que hem instal·lat un descalcificador a la casa, un grup d’osmosis a la cuina, hem fet una nova habitació a l’estudi, hem renovat l’WC del pis de d’alt, hem posat una nova pergola pel cotxe i nova teulada a la caseta de fusta del jardí. El millor de tot plegat és que personalment he participat força en l’execució d’aquestes d’algunes d’aquestes tasques.

Degut a l’embaraç del Roc aquest any les vacances han estat força diferents de l’habitual. Primer de tot varem fer una petita escapadeta a Puigcerdà durant un cap de setmana i després una setmaneta a Roses, bàsicament per descansar i disfrutar de la platja a més de poder estar junts com a parella. Ja que degut a la feina he passat un estiu força ocupat. Aprofitant les vacances a Roses també ens varem acostar fins a Empuria Brava per provar el Windoor que m’havia regalat l’Estefania per l’aniversari.

A nivell de creixement personal, aquest any hem tingut un creixement important a M2M Cloud Factory i ens hem començat a consolidar com a empresa, producte i amb grans i bons clients; tot això m’ha fet evolucionar moltíssim perquè l’excés de feina i l’altíssima demanda que ha tingut la feina sobre la meva energia ha estat esgotador. A més grans persones de l’empresa ens han deixat; com ara el Marc i el Pau i això encara ha augmentat més l’exigència. Però al final tot passa per algo i sempre hi ha lectures positives a tots els esdeveniments.

Tot i amb això he pogut incorporar tres noves formacions al meu currículum, un parell de cursos de comptabilitat. Un d’introducció i l’altre d’anàlisis de balanços. Però el que realment m’ha fet creixer personalment ha estat el de Management 3.0. Un curs increible, on no només se m’han obert les portes a una nova forma de fer les coses sinó també uns contactes boníssims i la possibilitat de col·laborar dins del meu departament amb un advisor excepcional, el Gabri.

Les meves rutines matutines, fent meditació a primera hora del matí; les preguntes per enfocar el dia i després fer-ne balanç i molts d’altres exercicis que heredo de la PNL, el mindfulness i d’altres disciplines m’han anat acompanyant durant tot l’any. Estic molt content del nivell de fidelitat que tinc amb totes aquestes pràctiques i sovint n’agraeixo els beneficis.

Gràcies a l’Horizon 2020 que varem guanyar l’any passat a M2MCF ens hem pogut centrar en crear un nou producte el MIIMETIQ LITE que veurà la llum ben aviat, a més d’haver creat una nova solució basada en les Smart Glasses. Mentre treiem noves versions del “framework”. Tot plegat ha tingut força repercusió a la prensa. Personalment hem van fer una entrevista al diari Ara referent a aquests temes: L’Internet de les coses: un futur a la punta dels dits.

Professionalment també he pogut tancar finalment el projecte Empowering. Més de dos anys de projecte al costat del Xavi i la gent del BEE group (CIMNE). Finalment el meu contracte va espirar el mes de setembre i vaig poder posar punt i final a aquest projecte de Big Data tan interessant i al que li desitjo el millor. A més com a consultor de l’empresa IUL, conjuntament amb l’Adrià com a part de l’equip de Nakima també hem pogut crear un parell de productes en un temps rècord i amb una orientació tecnològica molt ben enfocada cap al IoT.

Tot plegat m’ha permès tocar força tecnologies tot i que moltes d’elles ja les coneixia. Voldria destacar-ne algunes: OpenWRT, Raspbery PI, Rancher, Ambari, NodeJS, NodeRED, ESP8266, IrDA, RF, etc. Finalment també he aprofitat per canviar de portàtil i he jubilat el Mac Book Air que tenia. Tot i ser un i7 amb 4G de RAM i 256GB de SSD, el seu rendiment és ridicul al costat del Toshiba Portégé que amb el i7 de dos cossos, 16GB de RAM i 500GB d’SSD vola. Comentar que li vaig canviar el disc mSATA que portava de serie perquè no podia ser de més de 256GB. A més aquest nou portàtil té tots els ports que hem calen integrats, fins hi tot un mòdem 4G. Cosa que hem permet no haver d’anar pel món amb la maleta plena de cables.

Abans de tancar aquest resum anual afegir que aquest any he donat tres conferències. L’Àlex i la gent de la UPC van tornar a confiar amb mi perquè a inicis d’any fes de nou una conferència per la gent del FIB Alumni, aquest cop sobre la meva SmartHome. Arran d’aquesta conferència en Marc organitzador del IoT meetup de Barcelona em va demanar que la repetís en anglès per la gent del meetup. Finalment a la Garrotxa Camp també van voler que la tornés a fer.

També gràcies al Josep Maria la gent de l’Ara van voler fer-me una entrevista a tota pàgina que va sortir el dia de la diada. Sincerament hem va agradar força com van resumir la meva vida professional sense entrar en detalls. Obviament es van deixar mil coses però fer un article sobre la meva vida professional no és senzill i crec que ho van aconseguir prou bé. A més arran d’aquest article al butlletí de la gent gran de Torrelavit també hem van voler entrevistar, cosa que hem va fer molta il·lusió.

Un altre any plè de grans events, oportunitats i emocions profundes viscudes a flor de pell. Un any que varem acomiadar amb l’Àlex i Sarai (els “cunyis”) a Benifaió amb un sopar excel·lent i de forma relaxada. Abraçant aquest 2016 plè d’esperances, il·lusió i amb moltíssimes ganes de viure i estimar. Des del cor i els braços oberts de nou: GRÀCIES!!!

Raspberry PI and OpenWRT flash partition proposal and rescue boot support for embedded systems

Reading time: 4 – 7 minutes

Introduction

Main target of this post is describe how to organize flash partitions and how to modify default OpenWRT boot sequence to support a flexible and powerful rescue mode for Raspberry PI based projects. Just to clarify the explaination. When OpenWRT is build on a flash card for Raspberry, there are only two partitions.

The first one is vFat partition with kernel, firmware and other configuration files; the second one is a ext4 partition with root filesystem. Boot sequence loads the kernel and then mount root partition and run the init script. If ext4 filesystem is corrupted or could not be mounted boot sequence is stoped and there is no solution without extracting the flash card.

Features

In this blog entry I’m going to describe a partition table and boot sequence strategy to avoid this kind of problems. Of course, there are other solutions to get similar results but I think this one is simple and powerful at the same time.

Summarizing features of this solution:

  • reduce risk when using intensive writing app
  • reduce damage risk on flash memories
  • fail-safe mode pressing a button
  • support application upgrades using opkg packages
  • support operative system upgrades using opkg packages

This solution proposal assume:

  • wear leveling protection solved by flash card
  • button connected to GPIO pins

The idea

Raspberry PI requires a vfat partition as its first flash partition where there are several required files for booting process, this is a bootloader substitution. For example, in that partition there are files like: start*.elf and bootcode.bin which are the GPU firmware and bootloaders. Another key file is kernel.img; this is the kernel used for booting. Bootloader parameters for kernel booting are in a file called cmdline.txt and firmware parameters are set in config.txt.

At this point the most important think to take into account is kernel.img file and cmdline parameters. Because kernel is loaded and executed by default with cmdline parameters set. When kernel boot process finishes root filesystem and init process sequence will be figured out from cmdline parameters.

At this point take a look on proposed partition table could be useful: (spaces are just as a reference, use what you need)

p1 - vfat (~50MB)
p2 - ext4 - operative system base (read-only) (~150MB)
p3 - ext4 - operative system (read-write) (~250MB)
p4 - logical partition
  p4.1 - ext4 - your_application files (usually read-only)
  p4.2 - ext4 - your_application data (usually read-write)

Fail-safe boot process key is partition p2 where a minimal OpenWRT installation with a modified init sequence is found. Main idea here is detect if a GPIO shortcut is done, usually this is done just pressing a physical button and you can interact with the user emitting some beep, for example, you can tell the user when you are waiting for button press using a beep and then emit two beeps when button press is detected or nothing if no button is pressed in 3 seconds. Finally the idea is detect if you need a regular boot or a fail-safe boot.

My suggestion for minimal OpenWRT is a small footprint installation of OpenWRT without kernel modules, just the monolitic kernel loaded. Then reduce init sequence to the minimum and add fail-safe logic (GPIO button capture); if button is pressed stop boot sequence and give a shell to the user. Regular way will be invoke init file of the rootfs (p3 in the partition table).

I think the idea is simple and the complexity is reduced in two parts both of them are the init file. To be more precise the p2 partition table has its own init file and p3 the other one. p2 init file load the minimum hardware to control button and give rescue environment when it’s needed. And p3 init file mounts read-write partition and the regular filesystem with regular boot processes and all kind of stuff that you need.

Final notes

I know this is not a very practical post, but my intention is only share some ideas that I have in mind. I spend most of my time designing architectures and I think this is a very powerful architecture of a boot sequence for some professional projects based on Raspberry PI and OpenWRT.

The best way to do what I describe in this post is putting p2 in a initrd file which is referenced in kernel parameters. Because then all read-only system is a RAM partition and rootfs init file has the PID 1 dropping dual-init file complexity. But I decided to modify this part because in the past I had some problems creating initrd files specially when required space for that partition is bigger than RAM. Anyway it’s important to take in account that initrd files has the same purpose as the proposed p2 partition.

Useful links

Small recap of web shell applications

Reading time: 2 – 2 minutes

Lately I found some useful web applications that publish a terminal application. This is very useful when you are traveling or you have a remote server which you want to maintain or access from anywhere. Also another interesting use of this kind of applications is as a terminal for embedded devices.

I tried to use them as my default applications but all of them have the same problem: keyboard shortcuts conflict with the browser. I’m very used to use a lot of shortcuts to manage my terminal application and remote shell and this is a problem because most of the shortcuts are redefined by your browser. May be it’s possible to disable browser shortcuts when you are using this kind of web applications but I didn’t find how.

I hope this small list is as much useful for you as it is for me:

  • Wetty = Web + tty (the best one IMHO)

wetty

ajaxterm

anyterm

gateone

Secure download URLs with expiration time

Reading time: 4 – 6 minutes

Requirements

Imagine a HTTP server with those restrictions:

  • only specific files can be downloaded
  • with a limited time (expiration date)
  • an ID allows to trace who download files
  • with minimal maintenance and dependencies (no databases, or things like that)

the base of the solution that I designed is the URL format:

http://URL_HOST/<signature>/<customer_id>/<expire_date>/<path_n_file>
  • signature: is calculated with the next formula, given a “seed”
    • seed = “This is just a random text.”
    • str = customer_id + expire_date + path_n_file
    • signature = encode_base64( hmac_sha1( seed, str))
  • customer_id: just an arbitrary identifier when you want to distinguish who use the URL
  • expire_date: when the generated URL stops working
  • path_n_file: relative path in your private repository and the file to share

Understanding the ideas explained before I think it’s enough to understand what is the goal of the solution. I developed the solution using NGINX and LUA. But the NGINX version used is not the default version is a very patched version called Openresty. This version is specially famous because some important Chinese webs works with that, for instance, Taobao.com

Expiration URL solution Architecture schema

In the above schema there is a master who wants to share a file which is in the internal private repository, but the file has a time restriction and the URL is only for that customer. Then using the command line admin creates a unique URL with desired constrains (expiration date, customer to share and file to share). Next step is send the URL to the customer’s user. When the URL is requested NGINX server evaluates the URL and returns desired file only if the user has a valid URL. It means the URL is not expired, the file already exists, the customer identification is valid and the signature is not modified.

NGINX Configuration

server {
 server_name downloads.local;

 location ~ ^/(?<signature>[^/]+)/(?<customer_id>[^/]+)/(?<expire_date>[^/]+)/(?<path_n_file>.*)$ {
 content_by_lua_file "lua/get_file.lua";
 }

 location / {
 return 403;
 }
}

This is the server part of the NGINX configuration file, the rest of the file can as you want. Understanding this file is really simple, because the “server_name” works as always. Then only locations command are relevant. First “location” is just a regular expression which identifies the relevant variables of the URL and passes them to the LUA script. All other URLs that doesn’t match with the URI pattern fall in path “/” and the response is always “Forbiden” (HTTP 403 code). Then magics happen all in LUA code.

LUA scripts

There are some LUA files required:

  • create_secure_link.lua: creates secure URLs
  • get_file.lua: evaluates URLs and serves content of the required file
  • lib.lua: module developed to reuse code between other lua files
  • sha1.lua: SHA-1 secure hash computation, and HMAC-SHA1 signature computation in Lua (get from https://github.com/kikito/sha.lua)

It’s required to configure “lib.lua” file, at the beginning of the file are three variables to set up:

lib.secret = "This is just a long string to set a seed"
lib.base_url = "http://downloads.local/"
lib.base_dir = "/tmp/downloads/"

Create secure URLs is really simple, take look of the command parameters:

$ ./create_secure_link.lua 

 ./create_secure_link.lua <customer_id> <expiration_date> <relative_path/filename>

Create URLs with expiration date.

 customer_id: any string identifying the customer who wants the URL
 expiration_date: when URL has to expire, format: YYYY-MM-DDTHH:MM
 relative_path/filename: relative path to file to transfer, base path is: /tmp/downloads/

Run example:

$ mkdir -p /tmp/downloads/dir1
$ echo hello > /tmp/downloads/dir1/example1.txt
$ ./create_secure_link.lua acme 2015-08-15T20:30 dir1/example1.txt
http://downloads.local/YjZhNDAzZDY0/acme/2015-08-15T20:30/dir1/example1.txt
$ date
Wed Aug 12 20:27:14 CEST 2015
$ curl http://downloads.local:55080/YjZhNDAzZDY0/acme/2015-08-15T20:30/dir1/example1.txt
hello
$ date
Wed Aug 12 20:31:40 CEST 2015
$ curl http://downloads.local:55080/YjZhNDAzZDY0/acme/2015-08-15T20:30/dir1/example1.txt
Link expired

Little video demostration

Resources

Disclaimer and gratefulness

 

 

Conferència Summer Camp Garrotxa 2015: SmartHome usant Arduino, Raspberry PI i més

Reading time: 1 – 2 minutes

Aquest cap de setmana vaig tornar a donar la meva conferència sobre “SmartHome” en aquesta ocasió vaig introduïr la novetat del sistema de feedback basat en “Tasker + Auto-notification”, a més de l’execusió de tasques basades en “crontab”. També he inclòs un petit avanç sobre el nou projecte en el que estic treballant per tal d’integrar les dades del descalcificador dins del OpenHAB usant una webcam i OpenCV per processar les imatges optingudes.

Agraïr al Xavi, Gerardo i la Laura per haver-me donat aquesta oportunitat. Tant el SCG15 com el SAX2015 són events molt familiars a més l’entorn és espectacular. Tot un descobriment del que malgrat tenir referències no havia pogut disfrutar en primera persona.

scg2015

Free dynamic DNS service

Reading time: < 1 minute A long time ago there were several free dynamic DNS services but nowadays it's difficult to find one of them. And when you find the service usually you have some important restrictions like: number of updates per day or only few subdomains per account. But in the end I found a good free service of that, it's part of the project guifi.net and is called: Qui; you only need a guifi.net account to use the service and it’s really simple and clear. From my part the compatibility with “ddclient” and the “mikrotik” script are really useful and I want tu highlight this functionality.

Conference: SmartHome using Arduino, Raspberry PI and more

Reading time: 1 – 2 minutes

I did this conference twice but this time it’s in English as I said before in Catalan, this is how I’m getting real a childhood dream. Thanks to open hardware like Arduino and Raspberry PI and open source software like OpenHab I have a smarthome with several automations. Last Thursday I spoke in “IoT Barcelona meetup” sharing my personal experience automating my house.

If you lost it and you want to watch the presentation video is here:

and the presentations slides are here:

VMWare trick: add new hard drive without restarting the virtual machine

Reading time: < 1 minute As simple as that, if you add a new virtual hard drive using VMWare in your virtual machine with Linux and you want to force the re-scan SCSI bus to see the new hard drive when you run, for example: "fdisk -l". You can force the SCSI bus re-scan with:

# take into account that your new hard drive could be added in different point than “host0”
echo “- – -” > /sys/class/scsi_host/host0/scan

Conferència: SmartHome usant Arduino, Raspberry PI i més

Reading time: 1 – 2 minutes

El dia 12 de febrer al vespre vaig fer una conferència a la FIB (Facultat d’Informàtica de Barcelona) dins de la UPC (Universitat Politècnica de Catalunya). En aquesta xerra vaig estar explicant com vaig convertint en realitat un somni que vaig tenir quan era petit, estic parlant de domotitzar la casa. Gràcies a enginys com l’Arduino i la Raspberry PI a més d’aplicacions com l’OpenHab podem fer assequible allò que si anem a grans marques comercials es fa caríssim pel meu pressupost.

En aquest enllaç podeu trobar les transparències de:  SmartHome usant Arduino Raspberry i més i el video el teniu disponible al servidor de la FIB.

Ara també teniu disponible el video a youtube:

i podeu veure les transparències des d’aquest mateix post:

Espero els vostres feedbacks als comentaris, desitjo que ús sigui útil.

Turn on virtual machines in VMWare ESXi

Reading time: < 1 minute Next commands are very useful when you don't have access to the vSphere UI and you have to access to VMWare Hypervisor using SSH or console:

# get the list of virtual machines
vim-cmd vmsvc/getallvms

# get the state of a VM with #id: VM_ID
vim-cmd vmsvc/power.getstate VM_ID

# turn on the virtual machine with #id: VM_ID
vim-cmd vmsvc/power.on VM_ID

Another option to turn on the virtual machine using an Ansible playbook:

- hosts: vmware
  gather_facts: false
  tasks:
    - vsphere_guest:
        vcenter_hostname: "X.X.X.X"
        username: "{{ hostvars[inventory_hostname].ansible_ssh_user|quote }}"
        password: "{{ hostvars[inventory_hostname].ansible_ssh_pass|quote }}"
        guest: "NAME_OF_THE_VM"
        state: "powered_on"
      delegate_to: localhost