Sunday, April 8, 2018

The blog has moved

I know, who cares?

I think that I will no longer update this blog.
I want to explore new ways to spread my crappy ideas and rubbish. :-)
I want to try the way to self host a blog. Nothing serious, as always.

However you can find my further posts here: https://blog.oless.xyz

Monday, November 27, 2017

micro:bit, bluetooth and Linux




 
After various efforts I was able to read micro:bit sensors data from Linux. While temperature, and accelerometer data is not too difficult to collect, the UART service took a little more time, mainly due to a known issue in the micro:bit BLE implementation.

Here you can find my observations and experiments, with sample Python scripts: https://github.com/alcir/microbit-ble

Saturday, August 5, 2017

Add speech to your Fedora system

This article first appeared on Fedora Magazine

By default, Fedora Workstation ships a small package called espeak. It adds a speech synthesizer — that is, text-to-speech software.
In today’s world, talking devices are nothing impressive as they’re very common. You can find speech synthesizers even in your smartphone, a product like Amazon Alexa, or in the announcements at the train station. In addition, synthesized voices are nowadays more or less similar to human speech. We live in a 1980s science fiction movie!
The voice produced by espeak may sound a bit primitive compared to the aforementioned tools. But at the end of the day espeak produces good quality speech. And whether you find it useful or not, at least it can provide some amusement.

Running espeak

In espeak you can set various parameters using command line options. Examples include:
  • amplitude (-a)
  • pitch adjustment (-p)
  • speed of sentences (-s)
  • gap between words (-g)
Each of these options produces various effects and may help you achieve a cleaner voice.
You can also select different voice variants with command line options. For example, try -ven+m3 for a different English male voice, and -ven+f1 for a female one. You can also use different languages. For a list, run this command:
espeak --voices
Note that many languages other than English are experimental attempts.
To create a WAV file instead of actually speaking something, use the -w option:
espeak -w out.wav "Audio file test"
The espeak utility also reads the content of a file for you.
espeak -f plaintextfile
Or you can pass the text to speech from the standard input. In this way, as a simple example, you can build a talking box that alerts you to an event using a voice. Your backup is completed? Add this command to the end of your script:
echo "Backup completed" | espeak -s 160 -a 100 -g 4
Suppose an error shows up in a log file:
tail -1F /your/log/file | grep --line-buffered 'ERROR' | espeak
Or perhaps you want a speaking clock telling you every minute what time it is:
while true; do date +%S | grep '00' && date +%H:%M | espeak; sleep 1; done
As you can guess, use cases are limited only by your imagination. Enjoy your new talking Fedora system!

Friday, July 14, 2017

Firefox: usare la CNS su Fedora

La presente guida ha funzionato per me, su Fedora 26. Probabilmente è valida per altre distribuzioni di GNU/Linux (usando il gestore di pacchetti opportuno).
Guida per modo di dire, poiché i passi da seguire sono veramente semplici.
Alla fine del conto per installare il lettore e la Carta Nazionale dei Servizi (o Tessera Sanitaria), la procedura descritta sul sito della Regione Toscana  si rivela macchinosa e inutile.
Viene qui usato un lettore di smartcard B4ID
La carta invece è quella che sul sito della Regione viene identificata come modello 2 (AT2012).


Installare i pacchetti

Installate PC/SC Lite (Middleware to access a smart card using SCard API)

sudo dnf install pcsc-tools

Collegate il lettore e lanciare il comando:

pcsc_scan -n

Inserite la carta nel lettore. Dovrebbe apparire qualcosa del genere:

Fri Jul 14 19:51:49 2017
Reader 0: ACS ACR 38U-CCID 00 00
  Card state: Card inserted,
  ATR: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX X


Quindi ok, il lettore funziona.
Se non funziona: SPIPPOLATE.

Abilitate il servizio e fatelo partire:

sudo systemctl start pcscd
sudo systemctl enable pcscd.service


Installate OpenSC (Open source smart card tools and middleware):

sudo dnf install opensc

Firefox

Andate in Preferenze -> Avanzate -> Certificati
Quindi Dispositivi di Sicurezza
Pigiate sul tasto Carica
Come nome del modulo mettete quel che vi pare
Specificate quindi il percorso della libreria: /usr/lib64/opensc-pkcs11.so
Premete ok.

A questo punto dovreste vedere un nuovo device.


Inserendo la carta dovrebbe apparire il nominativo e il codice fiscale.


Premendo su Login dovrebbe venire richiesto il PIN della carta.

Ora potete
provare l'effettivo funzionamento collegandovi a un sito che richiede l'autenticazione via CNS, come per esempio https://accessosicuro.rete.toscana.it (dove trovate, fra l'altro, il Fascicolo Sanitario elettronico), oppure https://iris.rete.toscana.it/ (per i pagamenti online della Regione Toscana). oppure il sito dell'INPS.

Con la tessera sanitaria è anche possibile richiedere le credenziali SPID, il Sistema Pubblico di Identità Digitale: https://www.spid.gov.it/richiedi-spid#altre-modalita

Wednesday, July 12, 2017

How to install Fedora 26 on the Raspberry Pi (Headless and Wireless)

The Raspberry Pi is the most famous SBC (Single-Board Computer). It is a recent news that over five millions of units were sold since it came out.

There are a lot of Linux-based and not Linux-based operating systems that runs on the Raspberry: Fedora is one of the latest landed in this platform. Due to this fact, many things still don’t work: for instance, according to what you can read on the Fedora wiki, expansion HATs, composite TV out, analog sound port and the add-on camera are not yet supported; support for displays other than the official one is not currently planned, GPIO isn't well supported. In addition Fedora supports only Pi version 2 and later.
Obviously the Raspberry Pi Foundation recommends the use of Raspbian, a Debian-based Linux operating system. And as stated before, there are many distributions that have been around for a long time, therefore they probably work better on such platform. Compared to the rest of the world Fedora on ARM could look at early stages of development.
Then, due to these facts the question could be: why using Fedora on the Raspberry Pi when there are more feature rich and widely used distributions? The answer is: isn’t Fedora our favorite distro? So let’s give a try to the ARM version.
Side note: ARM is an architecture officially supported by Fedora.

Let’s get started.


Preparing the SD card

The installation of the Fedora ARM image on an SD card is simple as these two steps:

- download the raw image of your choice (in this case Minimal) from https://arm.fedoraproject.org/

- run this command (supposing you are running Fedora on your PC and that you have installed the fedora-arm-installer package via DNF)

sudo arm-image-installer --image=Fedora-Minimal-armhfp-26-1.5-sda.raw.xz --target=rpi3 --norootpass --resizefs --media=/dev/mmcblk0 -y

Please refer to the Fedora wiki.

Such command will blanks the root password (remember to subsequently set one during first setup) and it will automatically resize the root partition in order to fill up the SD card size.

Once done, remove the SD card from your PC.

The serial console

If you do not have an HDMI screen to connect to the Raspberry Pi, or if you want to run a completely headless box, you have to enable the serial console.

The task is different between the Raspberry 2 and 3. These steps are for the version 3:

- insert the SD card in your PC, it should automatically mount three partitions

- edit the file extlinux.conf

sudo vim /run/media/youruser/__boot/extlinux/extlinux.conf

add "console=tty0 console=ttyAMA0,115200" to the end of the append line

append ro root=UUID=<uuid-uuid> console=tty0 console=ttyS0,115200

- edit the config.txt file in the root partiton

sudo vim /run/media/youruser/sometinglike-4AC9-BABE/config.txt
uncomment the enable_uart line:

enable_uart=1

The onboard wifi adapter

If you want to enable the onboard WiFi adapter, you have to download a file that Fedora can not currently redistribute in the raw image:

sudo curl https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm80211/brcm/brcmfmac43430-sdio.txt -o /run/media/youruser/__/lib/firmware/brcm/brcmfmac43430-sdio.txt
 

Booting the Raspberry

Umount the three partitions, using something like

umount /run/media/youruser/__boot ; umount /run/media/youruser/__ ; umount /run/media/youruser/sometinglike-4AC9-BABE

Then insert the SD card in the Raspberry Pi, connect an Usb to Serial/TTL Adapter (the pin 8 on the Raspberry is the TX and pin 10 is the RX). Then power up the device.

You can look at the boot process using a terminal emulator program like minicom or GTKterm, or even the simple screen command:

screen  /dev/ttyUSB0 115200

Once the boot process will reach the end, you should see the Fedora initial setup where you can create an account, set the root password, configure the timezone, etc.

As soon as you log in, if the Raspberry is connected to the network using the Ethernet interface, and there is a DHCP server in the LAN, you are almost done. Check if you are really online and perform a system update:

sudo dnf update

Setup the wifi

If for some reason you can’t use the Ethernet interface and you need to connect to the WiFi network, you have to configure the wireless interface using the Network Manager command line interface (nmcli).

For instance, if your network uses WPA or WPA2, and there is a DHCP this task is pretty simple:

nmcli radio

nmcli device wifi connect YOURSSID password secretpassword

If you need to set up a static IP there are instead various steps to perform:

Add a connection profile and set the IP/netmask and the default gateway

nmcli con add con-name ConnectionName ifname wlan0 type wifi ssid YOURSSID ip4 192.168.100.200/24 gw4 192.168.100.1

Set up the DNS

nmcli con modify ConnectionName ipv4.dns "8.8.8.8 8.8.4.4"

Configure the wireless security (in this case wpa-psk) and the password

nmcli con modify ConnectionName wifi-sec.key-mgmt wpa-psk

nmcli con modify ConnectionName wifi-sec.psk verysecurepassword

Now you can bring up the connection:

nmcli con up ConnectionName

Conclusion

Here we have an headless and wireless Raspberry Pi 3 running our favorite GNU/Linux distribution!

Please refer to the Fedora Project wiki for more and up to date informations:
https://fedoraproject.org/wiki/Raspberry_Pi

Tuesday, May 23, 2017

How to print ZFS filesystems ordered by space used

How to print ZFS filesystems ordered by space used

zfs get -o value,name -Hp used|sort -n

Saturday, May 20, 2017

rpmbuild random notes

sudo dnf install rpmdevtools

rpmdev-setuptree

~/rpmbuild/SRPMS/
~/rpmbuild/SPECS/
~/rpmbuild/SOURCES/
~/rpmbuild/RPMS/
~/rpmbuild/BUILD/
~/.rpmmacros

sudo dnf download --source package

Thursday, March 9, 2017

Fedora dnf history

Sometimes it can happen that you remove a package and inadvertently you remove a bunch of dependencies. Like removing the entire desktop manager: what a mess, waht a pain in the ass!
Sometimes dependecies are strange.

Rarely, but it can happen too, after an update something doesn't work anymore. Maybe the updated package is buggy? Better waiting for a fix.

By the way. If you install or uninstall packages by mistake, there is a way to rollback the changes: history.

sudo dnf history list

And you can see the dnf activities.

sudo dnf history info 132

You can see the details of the dnf command labeled as 132

Let's say 132 is the number of the last action

ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   132 | update                   | 2017-03-09 16:06 | Update         |    8 

Issue the following command in order to uninstall these updates:

sudo dnf history undo 132

And you will get something like:

Undoing transaction 132, from Thu Mar  9 21:06:10 2017
No package libgdata-0:0.17.6-3.fc25.x86_64 available.
Error: An operation cannot be undone

Well. WTF!

It seems that, if you would like to have the option to rollback updates, you must enable packages cache beforehand with keepcache=1 in the /etc/dnf/dnf.conf configuration file. This could lead to some disk space used to store previous versions of rpms? I must investigate a bit deeper.

References: 

Monday, March 6, 2017

Tuesday, February 21, 2017

Oracle Database Appliance: random notes

How to create a shared repository

[root@oda11 ~]# oakcli create repo shared1 -dg data -size 50G

How to import a VM template

You must/can download a template from edelivery.oracle.com
You need to put the template or the assemly inside the DOM0, then import it from ODA_BASE.
[root@oda11 ~]# oakcli import vmtemplate prova -assembly /tmp/OVM_OL7U2_x86_64_PVHVM.ova -repo shared1 -node 0

How to create a VM

[root@oda11 ~]# oakcli clone vm pigna -vmtemplate prova -repo shared1 -node 0

How to create a vdisk

A vdisk that will be attacched to the VM
[root@oda11 ~]# oakcli create vdisk pignadiskl -repo shared1 -size 5G -type local

How to create a cpupool

The same pool name must be configured on each node.
[root@oda12 ~]# oakcli create cpupool provapool -numcpu 2 -node 1
[root@oda12 ~]# oakcli create cpupool provapool -numcpu 2 -node 0

How to configure the VM

Add two network interfaces

[root@oda11 ~]# oakcli configure vm pigna -network "['type=netfront,bridge=net1','type=netfront,bridge=net2']"

Enable failover

[root@oda11 ~]# oakcli configure vm pigna -failover true

Attach an additional disk

[root@oda11 ~]# oakcli modify vm pigna -attachvdisk pignadiskl

Configuring cpupool

[root@oda11 ~]# oakcli configure vm pigna -cpupool provapool

Starting the VM

[root@oda11 ~]# oakcli start vm pigna

Attacching to the console

You must ssh to the ODA_BASE using -Y flag.
[root@oda11 ~]# oakcli show vmconsole pigna
A VNC session will start

Expanding the disk space from inside the VM

This is the vdisk created before.
[root@pigna ~]# btrfs device add /dev/xvdb /
You can attach additional vdisks, and the VM OS will see them without the need to reboot it.

Adding space to the repo

[root@oda11 ~]# oakcli configure repo shared1 -incsize 25G

Monday, December 12, 2016

Percona Monitoring Plugins for Nagios on SmartOS

Using Percona monitoring plugins inside a SmartOS branded zone, I get an error related to the local command.

percona-monitoring-plugins-1.1.7/nagios/bin/pmp-check-mysql-innodb[58]: local: not found [No such file or directory]

To solve this problem, perform the following command against every script (i.e. inside the nagios/bin/ directory).

sed -i 's/^\( \{2,4\}\)local /\1typeset /' *

Monday, November 28, 2016

rsyslog gnutls: could not load module

Starting rsyslog with gnutls configured I got this error:

Nov 27 21:57:03 prometeo rsyslogd-2068: could not load module '/usr/lib64/rsyslog/lmnsd_gtls.so', rsyslog error -2078 [try http://www.rsyslog.com/e/2068 ]

The suggested link is not useful as the description (module could not be loaded - init failed) is too generic.

The problem here was that in the config file, the line DefaultNetstreamDriverCAFile was pointing to a non existent file.


Wednesday, June 15, 2016

We're sorry to see you go


We're sorry to see you go
Your LinkedIn account is now closed. Although you no longer have access to it, it'll take a few weeks for your public profile to disappear from search engines.
You may still receive invitations from LinkedIn members and groups.
Thanks,
The LinkedIn Team

Saturday, April 16, 2016

Giochini elettrificati

Per i lettori italiani.

Ho messo in piedi un sito vetrina dove condivido le mie creazioni elettroniche.
Oggetti altamente artigianali e dilettanteschi. Talvolta brutti e fatti male.

https://www.gioele.xyz

In questo sito raccolgo e presento qualche idea e qualche realizzazione, spesso maldestramente scopiazzate, di semplici e molto artigianali oggetti elettronici fatti in casa (circuiti e roba basata su Arduino) con cui far divertire in qualche modo bambine e bambini.
E magari, perché no, stimolare la loro curiosità nei confronti di hacking, DIY, elettronica e informatica.

Thursday, March 24, 2016

Arduino IDE and persistent serial port (Linux)

In the development of a little project with Arduino, I have to plug and unplug the USB cable a lot of times.
And I have a big annoyance: every time I plug the USB cable again, the port name changes from /dev/ttyUSB0 to /dev/ttyUSB1 and vice versa. So, in the IDE I have to go in Tools -> Port menu and select the right serial port every time before uploading the new sketch.
What a bore!

I've found this post, but the Arduino IDE seems that doesn't detect fancy names like /dev/arduino, but only names starting with "tty".

So my solution, in order to get a persistent name, is based on the http://hintshop.ludvig.co.nz/ blog post, but using a different port name:

sudo vi /etc/udev/rules.d/98-usb-serial.rules

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="ttyUSB10"

Reload udev rules with:

sudo udevadm control --reload-rules -R

Now in the IDE you can select this port and it never change every time you unplug and plug the USB cable.

Monday, March 14, 2016

OMD: python problem after CentOS yum update

After yum update I got a problem, related to python, with check_mk in the OMD implementation.

Environment:

  • CentOS 7
  • check_mk 1.2.4p5
  • omd-1.20


In the check_mk web page you can see a lot of messages like this in each "Check_MK inventory" check.

(Return code of 5 is out of bounds)

and if you issue the check_mk command you get

Cannot read file /omd/sites/prod/share/check_mk/modules/check_mk_base.py: 'frozenset' object is not callable

My solution was:

cp /omd/versions/1.20/lib/python/hashlib.py /omd/versions/1.20/lib/python/hashlib.py.OLD

cp /usr/lib64/python2.7/hashlib.py /omd/versions/1.20/lib/python/hashlib.py

Wednesday, February 10, 2016

SmartOS: how to clone a KVM machine

Get the disk0 filesystem of the VM to clone.

vmadm get uuid-originvm | json disks

[
  {
    "path": "/dev/zvol/rdsk/zones/uuid-originvm-disk0",
    "boot": true,
    "model": "virtio",
    "media": "disk",
    "image_size": 10240,
    "image_uuid": "d8e65ea2-1f3e-11e5-8557-6b43e0a88b38",
    "zfs_filesystem": "zones/uuid-originvm-disk0",
    "zpool": "zones",
    "size": 10240,
    "compression": "off",
    "refreservation": 10240,
    "block_size": 8192
  }
]

Take a snapshot

zfs snapshot zones/uuid-originvm-disk0@toclone

Create a json file in order to create the new VM.
vi targetvm.json
Please note: there are no disks.

{
  "alias": "targetvm",
  "hostname": "targetvm",
  "dns_domain": "mydomain.it",
  "brand": "kvm",
  "resolvers": [
    "192.168.0.2"
  ],
  "ram": "2048",
  "vcpus": "2",
  "nics": [
    {
      "nic_tag": "admin",
      "ip": "192.168.0.201",
      "netmask": "255.255.255.0",
      "gateway": "192.168.0.1",
      "model": "virtio",
      "primary": true
    }
  ]
}

vmadm create -f targetvm.json

Let's clone the filesystem of the origin VM.

zfs clone zones/uuid-originvm-disk0@toclone zones/uuid-targetvm-disk0

Create a json in order to add a disk to the new VM.
vi adddisk.json

{
   "add_disks": [
      {
          "media": "disk",
          "model": "virtio",
          "boot": true,
          "nocreate": true,
          "size": 10240,
          "path": "/dev/zvol/rdsk/zones/435ca788-4935-ead3-f4e4-94e6eb7dd4b6-disk0"
      }
   ]
}

Let's add the disk to the newly created VM.

vmadm stop uuid-targetvm -F

vmadm update uuid-targetvm -f adddisk.json

This is important.

zfs promote  zones/uuid-targetvm-disk0

From man zfs:

zfs promote clone-filesystem

    Promotes a clone file system to no longer be dependent on its "ori-
    gin" snapshot. This makes it possible to destroy  the  file  system
    that  the clone was created from. The clone parent-child dependency
    relationship is reversed, so that the origin file system becomes  a
    clone of the specified file system.

    The  snapshot  that  was cloned, and any snapshots previous to this
    snapshot, are now owned by the promoted clone. The space  they  use
    moves  from the origin file system to the promoted clone, so enough
    space must be available to  accommodate  these  snapshots.  No  new
    space  is  consumed  by this operation, but the space accounting is
    adjusted. The promoted clone must not have any conflicting snapshot
    names  of  its own. The rename subcommand can be used to rename any
    conflicting snapshots.

Tuesday, January 19, 2016

mod_jk apache 2.4 smartos zone

If, compiling mod_jk, you get

/usr/bin/bash: ../build/libtool: No such file or directory

Then

cd native/
./configure --with-apxs=/opt/local/bin/apxs
mkdir build
cp libtool build/
make
cp ./apache-2.0/mod_jk.so /opt/local/lib/httpd/