Jekyll2023-10-29T11:44:25+01:00https://cli.pignat.org/feed.xmlcli.pignat.orgmy tips and tricksRandomReaperQt6 windows static executables compiled from linux2022-09-14T00:00:00+02:002022-09-14T00:00:00+02:00https://cli.pignat.org/pages/qt-static-cross<p>Compiling Qt applications on windows for redistribution is utterly complicated, or impossible (missing dll, crashes, …). So here is a way to compile <em>static</em> qt application, from your preferred unix-like.</p>
<p>Tested on ubuntu 20.04. LTS, see <a href="http://mxe.cc" class="external">mxe.cc</a> for other unix-likes (even Mac OSX).</p>
<h2 id="installation">Installation</h2>
<ul>
<li>Install dependencies :
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="se">\</span>
autoconf automake autopoint bash bison bzip2 cmake flex <span class="se">\</span>
gettext git g++ gperf intltool libffi-dev libtool <span class="se">\</span>
libltdl-dev libssl-dev libxml-parser-perl make openssl <span class="se">\</span>
p7zip-full patch perl pkg-config python ruby scons <span class="nb">sed</span> <span class="se">\</span>
unzip wget xz-utils git lzip libtool-bin python3-mako
</code></pre></div> </div>
</li>
<li>Clone mxe:
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> ~/git <span class="o">&&</span> <span class="nb">cd</span> ~/git
git clone https://github.com/mxe/mxe.git
<span class="nb">cd </span>mxe
</code></pre></div> </div>
</li>
<li>Configure (create the file) <code class="language-plaintext highlighter-rouge">settings.mk</code> for 32 and 64 bit
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MXE_TARGETS := x86_64-w64-mingw32.static i686-w64-mingw32.static
</code></pre></div> </div>
</li>
<li>Compile it
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>make <span class="nt">-j9</span> qt6
</code></pre></div> </div>
</li>
</ul>
<h2 id="testing">Testing</h2>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Qt project creation</span>
<span class="nb">mkdir</span> /tmp/qt-test <span class="o">&&</span> <span class="nb">cd</span> /tmp/qt-test
<span class="nb">echo</span> <span class="s1">'QT += core gui opengl widgets
TEMPLATE = app
TARGET = hello
INCLUDEPATH += .
SOURCES += hello.cpp
'</span> <span class="o">></span> test.pro
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># main creation</span>
<span class="nb">echo</span> <span class="s1">'#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello RandomReaper !");
label->show();
return app.exec();
}
'</span> <span class="o">></span> hello.cpp
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#compiling</span>
<span class="nb">mkdir </span>build <span class="o">&&</span> <span class="nb">cd </span>build
<span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>~/git/mxe/usr/bin/:<span class="nv">$PATH</span>
~/git/mxe/usr/x86_64-w64-mingw32.static/qt6/bin/qmake ..
make
...
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Result</span>
file release/hello.exe
release/hello.exe: PE32+ executable <span class="o">(</span>GUI<span class="o">)</span> x86-64 <span class="o">(</span>stripped to external PDB<span class="o">)</span>, <span class="k">for </span>MS Windows
</code></pre></div></div>
<h2 id="compiling-an-existing-qt-project">Compiling an existing Qt project</h2>
<ul>
<li>Go to your project root (where the <code class="language-plaintext highlighter-rouge">.pro</code> is).</li>
<li>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir </span>build <span class="o">&&</span> <span class="nb">cd </span>build
<span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>~/git/mxe/usr/bin/:<span class="nv">$PATH</span>
~/git/mxe/usr/x86_64-w64-mingw32.static/qt6/bin/qmake ..
make
</code></pre></div> </div>
</li>
</ul>RandomReaperCompiling Qt applications on windows for redistribution is utterly complicated, or impossible (missing dll, crashes, …). So here is a way to compile static qt application, from your preferred unix-like.Raspberry Pi 4 boot from network2022-05-03T00:00:00+02:002022-05-03T00:00:00+02:00https://cli.pignat.org/pages/raspberry-pi-netboot<p>Network boot will allow to boot a Raspberry Pi without local storage, and will show
it’s full power when using several Raspberry Pi.</p>
<p>This post will show how to enable network boot on a Raspberry Pi 4, but I won’t talk
about the server setup (I may complete the post if <a href="/about/">requested</a>).</p>
<h2 id="first-time-client-setup">First time (client) setup</h2>
<p>The Raspberry Pi 4 may come with an EEPROM version that may prevent network booting, and in any case it is not factory activated, so the first step update the boot EEPROM and configure the Pi.</p>
<p>A single SD card may be reused for configuring and updating several Pi. I used <code class="language-plaintext highlighter-rouge">2022-04-04-raspios-bullseye-armhf-lite.img.xz</code>. For a headless install, you may have a look <a href="/pages/rasperry-pi-install-headless.html">here</a>.</p>
<p>I use <code class="language-plaintext highlighter-rouge">BOOT_ORDER=0xf2</code> to boot only from network and restart if it fails. See <a href="https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration" class="external">here</a> for a complete documentation of <code class="language-plaintext highlighter-rouge">BOOT_ORDER</code>.</p>
<p>Update and configure the Pi:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>PI_EEPROM_VERSION=pieeprom-2022-04-26
wget https://github.com/raspberrypi/rpi-eeprom/raw/master/firmware/stable/${PI_EEPROM_VERSION}.bin
sudo rpi-eeprom-config ${PI_EEPROM_VERSION}.bin > bootconf.txt
sed -i '/BOOT_ORDER=.*/d' bootconf.txt
echo 'BOOT_ORDER=0xf2' >> bootconf.txt
sudo rpi-eeprom-config --out ${PI_EEPROM_VERSION}-netboot.bin --config bootconf.txt ${PI_EEPROM_VERSION}.bin
sudo rpi-eeprom-update -d -f ./${PI_EEPROM_VERSION}-netboot.bin
</code></pre></div></div>
<h2 id="network-boot-information">Network boot information</h2>
<p>After the DHCP succeeds, (the DHCP answer may contain the TFTP server address), the Raspberry Pi will try to fetch the
same files it expects in the on a SD <code class="language-plaintext highlighter-rouge">/boot</code> partition.
The Raspberry will first try to download files named “SERIAL_NUMBER/filename” then “filename”, for instance “12345678/config.txt” and then “config.txt”. Using this mechanism, it’s possible to choose which Raspberry will load which OS from the network, with a fallback to a default.</p>
<p>Customizing the “SERIAL_NUMBER/cmdline.txt” can be used to provide a different filesystem for each Raspberry Pi on the network.</p>
<h2 id="boot-logs">Boot logs</h2>
<p>Just for the record, here are some boot logs.</p>
<h3 id="before-dhcp">Before DHCP:</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Raspberry Pi 4 Model B - 8GB
Bootloader: 778c182c 2022/03/10
board: 123456 1234578 dc:a6:32:XX:XX:XX
boot: mode NETWORK 2 order f2 retry 0/0 restart 0/-1
SD: card not detected
part: 0 mbr [0x00:00000000 0x0:000000000 0x0:000000000 0x0:000000000]
fw: star.elf fixup.dat
net: up ip: 0.0.0.0 sn: 0.0.0.0 gw: 0.0.0.0
tftp: 0.0.0.0 00:00:00:00:00:00
Boot mode: NETWORK (02) order f
Boot mode: NETWORK (02) order f
USB2[1] XXXXXXXX connected
USB2 root HUB port 1 init
</code></pre></div></div>
<h3 id="after-dhcp">After DHCP:</h3>
<ul>
<li>DHCP server IP : 75.748.86.1</li>
<li>TFTP server IP : 75.748.86.33</li>
<li>Pi IP : 75.748.86.91</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Raspberry Pi 4 Model B - 8GB
Bootloader: 778c182c 2022/03/10
board: 123456 1234578 dc:a6:32:XX:XX:XX
boot: mode NETWORK 2 order f2 retry 0/0 restart 0/-1
SD: card not detected
part: 0 mbr [0x00:00000000 0x0:000000000 0x0:000000000 0x0:000000000]
fw: star.elf fixup.dat
net: up ip: 75.748.86.91 sn: 255.255.255.0 gw: 0.0.0.0
tftp: 75.748.86.33 00:00:00:00:00:00
Boot mode: NETWORK (02) order f
Boot mode: NETWORK (02) order f
USB2[1] XXXXXXXX connected
USB2 root HUB port 1 init
NET_BOOT dc:a6:32:XX:XX:XX wait for link TFTP: 0.0.0.0
Link ready
DHCP src: XX:XX:XX:XX:XX:XX 75.748.86.1
YI_ADDR: 75.748.86.91
SI_ADDR: 75.748.86.1
[66]: 75.748.86.33
DHCP src: XX:XX:XX:XX:XX:XX 75.748.86.1
YI_ADDR: 75.748.86.91
SI_ADDR: 75.748.86.1
NET 75.748.86.91 255.255.255.0 gw 0.0.0.0 tftp 75.748.86.33
ARP 75.748.86.33 XX:XX:XX:XX:XX:XX
NET 75.748.86.91 255.255.255.0 gw 0.0.0.0 tftp 75.748.86.33
TFTP: 1: File not found
Read 1234578/config.txt bytes 1166 hnd 0x0
...
</code></pre></div></div>RandomReaperNetwork boot will allow to boot a Raspberry Pi without local storage, and will show it’s full power when using several Raspberry Pi.Raspberry PI OS headless install2022-04-12T00:00:00+02:002022-04-12T00:00:00+02:00https://cli.pignat.org/pages/rasperry-pi-install-headless<ul>
<li>Get Raspberry PI OS (I prefer the 64 bit-light).</li>
<li>Flash it (see <a href="https://www.raspberrypi.org/documentation/installation/installing-images/README.md" class="external">install guide</a>)</li>
<li>Mount the <code class="language-plaintext highlighter-rouge">/boot</code> partition, for instance in <code class="language-plaintext highlighter-rouge">/tmp/boot</code>, then run (with the username and password you want) :</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> cd /tmp/boot
touch ssh
echo 'mypassword' | openssl passwd -6 -stdin | sed -e 's/^/username:/' > userconf
</code></pre></div></div>
<ul>
<li>For wifi, put the file <code class="language-plaintext highlighter-rouge">wpa_supplicant.conf</code> in <code class="language-plaintext highlighter-rouge">/boot</code>, containing:</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>network={
ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
key_mgmt=WPA-PSK
}
</code></pre></div></div>RandomReaperGet Raspberry PI OS (I prefer the 64 bit-light). Flash it (see install guide) Mount the /boot partition, for instance in /tmp/boot, then run (with the username and password you want) :`ssh` configuration2021-04-01T00:00:00+02:002021-04-01T00:00:00+02:00https://cli.pignat.org/pages/ssh-config<p><a href="ssh-config-v0.html" class="update">here</a></p>
<p>The default <code class="language-plaintext highlighter-rouge">ssh</code> configuration shipped with your GNU/Linux distribution may not
be ideal. Here are some tweaks I use:</p>
<h2 id="idle-connection">Idle connection</h2>
<p>The remote ssh server (or a router/firewall in-between) may disconnect an idle
connection. To prevent that, it’s possible to send keep-alive from
the client site, by editing <code class="language-plaintext highlighter-rouge">/etc/ssh/ssh_config</code> or <code class="language-plaintext highlighter-rouge">~/ssh/config</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host *
...
ServerAliveInterval 240
...
</code></pre></div></div>
<p>or from the server side by editing <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>...
ClientAliveInterval 60
...
</code></pre></div></div>
<h2 id="known_host-and-changing-ip"><code class="language-plaintext highlighter-rouge">known_host</code> and changing IP</h2>
<p>IP addresses may be re-used on some networks, and storing the server fingerprint with the IP address
can be disabled.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host *
...
CheckHostIP no
...
</code></pre></div></div>
<h2 id="locales">Locales</h2>
<p>Using your local <a href="/tag/locale.html">locale</a> on a remote system may not be desirable, the remote host may try to use your a non existent locale and display a lot of warnings, for instance:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE <span class="o">=</span> <span class="s2">"en_US:en"</span>,
LC_ALL <span class="o">=</span> <span class="o">(</span><span class="nb">unset</span><span class="o">)</span>,
LC_TIME <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_MONETARY <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_ADDRESS <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_TELEPHONE <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_NAME <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_MEASUREMENT <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_IDENTIFICATION <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_NUMERIC <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LC_PAPER <span class="o">=</span> <span class="s2">"de_CH.UTF-8"</span>,
LANG <span class="o">=</span> <span class="s2">"en_US.UTF-8"</span>
are supported and installed on your system.
perl: warning: Falling back to a fallback locale <span class="o">(</span><span class="s2">"en_US.UTF-8"</span><span class="o">)</span><span class="nb">.</span>
locale: Cannot <span class="nb">set </span>LC_ALL to default locale: No such file or directory
</code></pre></div></div>
<p>To prevent your host from sending the locale edit <code class="language-plaintext highlighter-rouge">/etc/ssh/ssh_config</code> (or your user’s <code class="language-plaintext highlighter-rouge">~/.ssh/config</code>)
and and remove LANG and LC_* from the sent variables :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#SendEnv LANG LC_*
</code></pre></div></div>
<p>To prevent the remote machine form accepting the locale edit <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code> (dont’ forget the <strong>d</strong>)
and remove LANG and LC_* from the accepted environment variable:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#AcceptEnv LANG LC_*
</code></pre></div></div>RandomReaperhere`ssh` configuration2020-11-05T00:00:00+01:002020-11-05T00:00:00+01:00https://cli.pignat.org/pages/ssh-config<p>The default <code class="language-plaintext highlighter-rouge">ssh</code> configuration shipped with your distribution may not be ideal.
Here are some tweaks I use:</p>
<h2 id="idle-connection">Idle connection</h2>
<p>The remote ssh server (or a router/firewall in-between) may disconnect an idle
connection. To prevent that, it’s possible to send keep-alive from
the client site, by editing <code class="language-plaintext highlighter-rouge">/etc/ssh/ssh_config</code> or <code class="language-plaintext highlighter-rouge">~/ssh/config</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host *
...
ServerAliveInterval 240
...
</code></pre></div></div>
<h2 id="known_host-and-changing-ip"><code class="language-plaintext highlighter-rouge">known_host</code> and changing IP</h2>
<p>IP addresses may be re-used on some networks, and storing the server fingerprint with the IP address
can be disabled.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host *
...
CheckHostIP no
...
</code></pre></div></div>
<h2 id="locales">Locales</h2>
<p>Using your local <a href="/tag/locale.html">locale</a> on a remote system may not be desirable.
To prevent your host from sending the locale edit <code class="language-plaintext highlighter-rouge">/etc/ssh/ssh_config</code> (or your user’s <code class="language-plaintext highlighter-rouge">~/.ssh/config</code>)
and and remove LANG and LC_* from the sent variables :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#SendEnv LANG LC_*
</code></pre></div></div>
<p>To prevent the remote machine form accepting the locale edit <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code> (dont’ forget the <strong>d</strong>)
and remove LANG and LC_* from the accepted environment variable:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#AcceptEnv LANG LC_*
</code></pre></div></div>RandomReaperThe default ssh configuration shipped with your distribution may not be ideal. Here are some tweaks I use:Zabbix : store history and trends into `influxdb`2020-09-21T00:00:00+02:002020-09-21T00:00:00+02:00https://cli.pignat.org/pages/01-zabbix-store-influxdb<p>I’m not particularly fond of <a href="/tag/influxdb.html"><code class="language-plaintext highlighter-rouge">influxdb</code></a>, but since I know
it already and since any time-series database should work better than a standard SQL
database for time-series, let’s try to store zabbix history into <a href="/tag/influxdb.html"><code class="language-plaintext highlighter-rouge">influxdb</code></a>.</p>
<h2 id="setup">Setup</h2>
<ol>
<li>Install <a href="/tag/zabbix.html">zabbix</a>.</li>
<li>Install <a href="/tag/grafana.html">grafana</a>.</li>
<li>Install <a href="/tag/influxdb.html">influxdb</a> and configure authentication.</li>
<li>Install <code class="language-plaintext highlighter-rouge">go</code> and <code class="language-plaintext highlighter-rouge">pwgen</code>:
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt-get <span class="nb">install </span>golang-go pwgen
</code></pre></div> </div>
</li>
<li>Follow the chapter about your SQL database on <a href="https://github.com/zensqlmonitor/influxdb-zabbix" class="external">https://github.com/zensqlmonitor/influxdb-zabbix</a>.</li>
<li>Connect to influx, create the <code class="language-plaintext highlighter-rouge">zabbix</code> database, with the <code class="language-plaintext highlighter-rouge">zabbix</code> user for writing and <code class="language-plaintext highlighter-rouge">zabbix_ro</code> user for read-only access (from grafana).
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>CREATE database zabbix
CREATE USER zabbix WITH PASSWORD <span class="s1">'use pwgen for that field and take a note'</span>
CREATE USER zabbix_ro WITH PASSWORD <span class="s1">'use pwgen for that field and take another note'</span>
GRANT ALL ON zabbix TO zabbix
GRANT READ on zabbix TO zabbix_ro
</code></pre></div> </div>
</li>
<li>Create a user <code class="language-plaintext highlighter-rouge">zabbix-influx</code>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>useradd <span class="nt">-g</span> zabbix <span class="nt">-d</span> /var/lib/zabbix-influx zabbix-influx
<span class="nb">sudo chown</span> <span class="nt">-R</span> zabbix-influx:zabbix /var/lib/zabbix-influx
</code></pre></div> </div>
</li>
<li>Using the <code class="language-plaintext highlighter-rouge">zabbix-influx</code> user, install <code class="language-plaintext highlighter-rouge">github.com/zensqlmonitor/influxdb-zabbix</code>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo</span> <span class="nt">-u</span> zabbix-influx go get github.com/zensqlmonitor/influxdb-zabbix
<span class="nb">sudo</span> <span class="nt">-u</span> zabbix-influx <span class="nb">cp </span>go/src/github.com/zensqlmonitor/influxdb-zabbix/influxdb-zabbix.conf <span class="nb">.</span>
</code></pre></div> </div>
</li>
<li>Configure influx credentials, and SQL access using <code class="language-plaintext highlighter-rouge">sudoedit /var/lib/zabbix-influx/influxdb-zabbix.conf</code>, make sure to configure influx and mysql URLs, databases, users and password.</li>
</ol>
<h2 id="testing">Testing</h2>
<ol>
<li>This command will run the influxd-zabbix in foreground:
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo</span> <span class="nt">-u</span> zabbix-influx <span class="nt">-i</span>
go build github.com/zensqlmonitor/influxdb-zabbix
go <span class="nb">install </span>github.com/zensqlmonitor/influxdb-zabbix
./go/bin/influxdb-zabbix
</code></pre></div> </div>
<p>In fact, it will take all zabbix history and trends and put then into influx.</p>
</li>
<li>Go to grafana, configure a new source using influxdb, database:zabbix, user:zabbix_ro, …</li>
<li>Still in grafana, create a new dashboard and test the new data source.</li>
<li>When all is working, kill <code class="language-plaintext highlighter-rouge">influxdb-zabbix</code> using <kbd>CTRL-C</kbd>.</li>
</ol>
<h2 id="service">Service</h2>
<p>Now that the zabbix to influx bridge is working, make sur it runs in background,
so data are pushed into influx as soon as they are in zabbix.</p>
<ol>
<li>Reduce the verbosity and disable coloring for syslog: <code class="language-plaintext highlighter-rouge">sudoedit /var/lib/zabbix-influx/influxdb-zabbix.conf</code> and change:
<div class="language-config highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">levelconsole</span>=<span class="s2">"Warn"</span>
<span class="n">formatting</span>=<span class="n">false</span>
</code></pre></div> </div>
</li>
<li>Create the service file, using <code class="language-plaintext highlighter-rouge">sudoedit /etc/systemd/system/zabbix-influx.service</code> with the following content:
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[Unit]
Description=zabbix to influx data pusher
#
[Service]
Type=simple
Restart=always
RestartSec=5s
ExecStart=/var/lib/zabbix-influx/go/bin/influxdb-zabbix
User=zabbix-influx
Group=zabbix
WorkingDirectory=~
#
[Install]
WantedBy=multi-user.target
</code></pre></div> </div>
</li>
<li>Update systemd services
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo systemctl daemon-reload
</code></pre></div> </div>
</li>
<li>Enable and start the service
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo systemctl enable zabbix-influx
sudo systemctl start zabbix-influx
</code></pre></div> </div>
</li>
<li>Check
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemctl status zabbix-influx.service
</code></pre></div> </div>
<p>Should be <strong>Active (running)</strong>.</p>
</li>
<li>Have a break, then return to grafana and check if data are up-to date.</li>
</ol>RandomReaperI’m not particularly fond of influxdb, but since I know it already and since any time-series database should work better than a standard SQL database for time-series, let’s try to store zabbix history into influxdb.Thunderbird : security.dialog_enable_delay=02020-09-15T00:00:00+02:002020-09-15T00:00:00+02:00https://cli.pignat.org/pages/01-thunderbird-security-dialog<p>Tired of waiting one second when opening an attachement from <a href="/tag/thunderbird.html">Thunderbird</a>?</p>
<p>This annoying delay introduced for <em>security</em> purpose can be disable in the <code class="language-plaintext highlighter-rouge">Config Editor</code>.</p>
<p>Got to <code class="language-plaintext highlighter-rouge">Edit</code> > <code class="language-plaintext highlighter-rouge">Preferences</code> > <code class="language-plaintext highlighter-rouge">Advanced</code> > <code class="language-plaintext highlighter-rouge">Config Editor...</code> and set <code class="language-plaintext highlighter-rouge">security.dialog_enable_delay</code> to <code class="language-plaintext highlighter-rouge">0</code>.</p>RandomReaperTired of waiting one second when opening an attachement from Thunderbird?Understanding and configuring `locale`2020-09-08T00:00:00+02:002020-09-08T00:00:00+02:00https://cli.pignat.org/01-ch-locales<p><a href="/tag/ubuntu.html">ubuntu</a> (like most GNU/Linux distributions) is trying hard to
speak your language, even in the console, and not only the language, but also
the date and number formatting.</p>
<p>For instance:</p>
<ul>
<li>15,000 is 15 for an European<sup><a href="#_nb1">*1</a></sup> and 15E3 for an American.</li>
<li>09/08 may be September 8 or August 9<sup><a href="#_nb2">*2</a></sup>.</li>
</ul>
<h2 id="background">Background</h2>
<p>Programs use <a href="https://en.wikipedia.org/wiki/Environment_variable" class="external">environment variables</a>
to try to <em>translate</em> program output. Those environment variables are named <code class="language-plaintext highlighter-rouge">LANGUAGE</code>, <code class="language-plaintext highlighter-rouge">LC_ALL</code>, <code class="language-plaintext highlighter-rouge">LC_*</code> (<code class="language-plaintext highlighter-rouge">LC_TIME</code>, <code class="language-plaintext highlighter-rouge">LC_MONETARY</code>, …) and <code class="language-plaintext highlighter-rouge">LANG</code>.</p>
<p>Those variables contains the name of the <a href="/tag/locale.html"><code class="language-plaintext highlighter-rouge">locale</code></a>.</p>
<p>Example, show the current date format:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>echo LC_TIME=$LC_TIME
LC_TIME=en_US.UTF-8
</code></pre></div></div>
<p>Show the date of a file, using the current date format:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ls -lh /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Aug 10 11:58 /dev/ttyS0
</code></pre></div></div>
<p>Show the date of a file, forcing the date format:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>LC_TIME=fr_CH.UTF-8 ls -lh /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 aoû 10 11:58 /dev/ttyS0
</code></pre></div></div>
<h2 id="configuring-the-locales">Configuring the locales</h2>
<h3 id="using-system-tools">Using system tools</h3>
<p>Select the local you need.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dpkg-reconfigure locales
</code></pre></div></div>
<h3 id="manual-setup">Manual setup</h3>
<p>Edit <code class="language-plaintext highlighter-rouge">/etc/default/locale</code> as you want:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>LANG=en_US.UTF-8
LC_NUMERIC="fr_CH.UTF-8"
LC_TIME="en_DK.UTF-8"
LC_MONETARY="fr_CH.UTF-8"
LC_PAPER="fr_CH.UTF-8"
LC_NAME="fr_CH.UTF-8"
LC_ADDRESS="fr_CH.UTF-8"
LC_TELEPHONE="fr_CH.UTF-8"
LC_MEASUREMENT="fr_CH.UTF-8"
LC_IDENTIFICATION="fr_CH.UTF-8"
</code></pre></div></div>
<p>Edit <code class="language-plaintext highlighter-rouge">/etc/locale.gen</code>, uncomment the locales you need:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#...
# de_CH ISO-8859-1
de_CH.UTF-8 UTF-8
# de_DE ISO-8859-1
#...
# en_DK.ISO-8859-15 ISO-8859-15
en_DK.UTF-8 UTF-8
# en_GB ISO-8859-1
#...
# en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8
# en_ZA ISO-8859-1
#...
# fr_CH ISO-8859-1
fr_CH.UTF-8 UTF-8
# fr_FR ISO-8859-1
#...
</code></pre></div></div>
<p>Generate the locales with <code class="language-plaintext highlighter-rouge">sudo locale-gen</code>, if all <code class="language-plaintext highlighter-rouge">en</code> locales are generated, you may want to remove <code class="language-plaintext highlighter-rouge">/var/lib/locales/supported.d/local/en</code>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Generating locales (this might take a while)...
de_CH.UTF-8... done
en_DK.UTF-8... done
en_US.UTF-8... done
fr_CH.UTF-8... done
Generation complete.
</code></pre></div></div>
<h3 id="remote-locales-or-perl-warning-please-check-that-your-locale-settings">Remote locales or <code class="language-plaintext highlighter-rouge">perl: warning: Please check that your locale settings</code></h3>
<p>You may have seen that kind of warning:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE <span class="o">=</span> <span class="s2">"en_US:en"</span>,
LC_ALL <span class="o">=</span> <span class="o">(</span><span class="nb">unset</span><span class="o">)</span>,
LC_TIME <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_MONETARY <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_ADDRESS <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_TELEPHONE <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_NAME <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_MEASUREMENT <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_IDENTIFICATION <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_NUMERIC <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LC_PAPER <span class="o">=</span> <span class="s2">"fr_CH.UTF-8"</span>,
LANG <span class="o">=</span> <span class="s2">"en_US.UTF-8"</span>
are supported and installed on your system.
perl: warning: Falling back to a fallback locale <span class="o">(</span><span class="s2">"en_US.UTF-8"</span><span class="o">)</span><span class="nb">.</span>
locale: Cannot <span class="nb">set </span>LC_ALL to default locale: No such file or directory
</code></pre></div></div>
<p>It is usually caused by a connection through <a href="/tag/ssh.html">ssh</a>, where the host has configured some locales that are unavailable on the remote system.</p>
<h4 id="solution-1--add-the-missing-locales">Solution #1 : add the missing locales</h4>
<ol>
<li>Connect to the remote host</li>
<li>Edit <code class="language-plaintext highlighter-rouge">/etc/locale.gen</code>, add the missing locales</li>
<li>Generate the locales using <code class="language-plaintext highlighter-rouge">sudo locale-gen</code></li>
</ol>
<h4 id="solution-21--configure-your-local-ssh-not-to-send-locale-related-environment-variables">Solution #2.1 : configure your local ssh not to send locale-related environment variables</h4>
<ol>
<li>Edit <code class="language-plaintext highlighter-rouge">/etc/ssh/ssh_config</code> (or your user’s <code class="language-plaintext highlighter-rouge">~/.ssh/config</code>) and add :
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SendEnv LANG LC_*
</code></pre></div> </div>
</li>
</ol>
<h4 id="solution-22--configure-the-remote-system-ssh-not-to-accept-locale-related-environment-variables">Solution #2.2 : configure the remote system ssh not to accept locale-related environment variables</h4>
<ol>
<li>Edit <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code> (dont’ forget the <strong>d</strong>) and remove LANG and LC_* from the accepted environment variable:
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#AcceptEnv LANG LC_*
</code></pre></div> </div>
</li>
</ol>
<p>While you’re configuring ssh, have a look at <a href="/pages/ssh-keepalive.html"><code class="language-plaintext highlighter-rouge">ssh</code> keepalive</a>.</p>
<p><br /><a name="_nb1">*1</a> My <i>European</i> view may be based on the <a href="https://www.localeplanet.com/icu/fr-CH/" class="external">fr_CH locale</a>.
<br /><a name="_nb2">*2</a> Dates can be clearly defined using the <a href="https://en.wikipedia.org/wiki/ISO_8601" class="external">ISO 8601</a> format.</p>RandomReaperubuntu (like most GNU/Linux distributions) is trying hard to speak your language, even in the console, and not only the language, but also the date and number formatting.Get the Raspberry Pi model from the command line (update #1)2020-02-20T00:00:00+01:002020-02-20T00:00:00+01:00https://cli.pignat.org/pi-hw-cmdline<p>Don’t want to open the case of a Raspberry Pi to find it’s model? or are you
connected trough <code class="language-plaintext highlighter-rouge">ssh</code>? Here is how to identify your Pi from the command line!</p>
<h2 id="identification-">Identification #</h2>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">pi@some-random-pi:~$</span><span class="w"> </span><span class="nb">cat</span> /sys/firmware/devicetree/base/model
<span class="go">Raspberry Pi 3 Model B Rev 1.2
</span></code></pre></div></div>
<p><em>The old version of this post using revision number lies <a href="pi-hw-cmdline-v0.html">here</a>.</em></p>RandomReaperDon’t want to open the case of a Raspberry Pi to find it’s model? or are you connected trough ssh? Here is how to identify your Pi from the command line!`somu` - FIDO2 security key2020-01-31T00:00:00+01:002020-01-31T00:00:00+01:00https://cli.pignat.org/somu<p><a href="/tag/2fa.html">2FA</a> using an open source (hardware and firmware) key.</p>
<h2 id="setup">Setup</h2>
<p>Connect the security key, then create the file
<code class="language-plaintext highlighter-rouge">/etc/udev/rules.d/70-solokeys-access.rules</code>:</p>
<div class="language-config highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Notify ModemManager this device should be ignored
</span><span class="n">ACTION</span>!=<span class="s2">"add|change|move"</span>, <span class="n">GOTO</span>=<span class="s2">"mm_usb_device_blacklist_end"</span>
<span class="n">SUBSYSTEM</span>!=<span class="s2">"usb"</span>, <span class="n">GOTO</span>=<span class="s2">"mm_usb_device_blacklist_end"</span>
<span class="n">ENV</span>{<span class="n">DEVTYPE</span>}!=<span class="s2">"usb_device"</span>, <span class="n">GOTO</span>=<span class="s2">"mm_usb_device_blacklist_end"</span>
<span class="n">ATTRS</span>{<span class="n">idVendor</span>}==<span class="s2">"0483"</span>, <span class="n">ATTRS</span>{<span class="n">idProduct</span>}==<span class="s2">"a2ca"</span>, <span class="n">ENV</span>{<span class="n">ID_MM_DEVICE_IGNORE</span>}=<span class="s2">"1"</span>
<span class="n">LABEL</span>=<span class="s2">"mm_usb_device_blacklist_end"</span>
<span class="c"># Solo bootloader + firmware access
</span><span class="n">SUBSYSTEM</span>==<span class="s2">"hidraw"</span>, <span class="n">ATTRS</span>{<span class="n">idVendor</span>}==<span class="s2">"0483"</span>, <span class="n">ATTRS</span>{<span class="n">idProduct</span>}==<span class="s2">"a2ca"</span>, <span class="n">TAG</span>+=<span class="s2">"uaccess"</span>
<span class="n">SUBSYSTEM</span>==<span class="s2">"tty"</span>, <span class="n">ATTRS</span>{<span class="n">idVendor</span>}==<span class="s2">"0483"</span>, <span class="n">ATTRS</span>{<span class="n">idProduct</span>}==<span class="s2">"a2ca"</span>, <span class="n">TAG</span>+=<span class="s2">"uaccess"</span>
<span class="c"># ST DFU access
</span><span class="n">SUBSYSTEM</span>==<span class="s2">"usb"</span>, <span class="n">ATTRS</span>{<span class="n">idVendor</span>}==<span class="s2">"0483"</span>, <span class="n">ATTRS</span>{<span class="n">idProduct</span>}==<span class="s2">"df11"</span>, <span class="n">TAG</span>+=<span class="s2">"uaccess"</span>
<span class="c"># U2F Zero
</span><span class="n">SUBSYSTEM</span>==<span class="s2">"hidraw"</span>, <span class="n">ATTRS</span>{<span class="n">idVendor</span>}==<span class="s2">"10c4"</span>, <span class="n">ATTRS</span>{<span class="n">idProduct</span>}==<span class="s2">"8acf"</span>, <span class="n">TAG</span>+=<span class="s2">"uaccess"</span>
</code></pre></div></div>
<p>Then reload the rules:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>udevadm control <span class="nt">--reload-rules</span> <span class="o">&&</span> <span class="nb">sudo </span>udevadm trigger
</code></pre></div></div>
<h2 id="testing">Testing</h2>
<p><a href="https://webauthn.io/" class="external"><code class="language-plaintext highlighter-rouge">webauthn.io</code></a> can be used to test the security
key.</p>
<ol>
<li>Enter username</li>
<li>Click <strong>Register</strong> (you’ll be asked to confirm by touching your key), If your
key LED is on and this step does not work, you may double check the setup step.</li>
<li>Clikc <strong>Login</strong></li>
<li>Ta-dah!</li>
</ol>RandomReaper2FA using an open source (hardware and firmware) key.