Home About Meetings FOSS

December 14 2021 Quiz, mqcontrol, NextCloud backups, Redis

Posted on December 19, 2021
( 10 minute read )

John presented a short quiz to mark 30 years of Linux:

  1. On which teaching tool did Linus Torvalds base his original operating system?
  2. Which is the longest continuously available Linux distribution?
  3. Which company gave its software away and told customers they could pay for support?
  4. What does Debian stand for?
  5. For which processor did Linus Torvalds rewrite Linux?
  6. Which company did Sun buy because it was cheaper than licensing Microsoft Office?
  7. Why was the Gnome desktop created?
  8. When was Ubuntu first issued?
  9. Apart from the Linux kernel, what other programs has Linus Torvalds created?
  10. Which software does Android use instead of the GNU utilities?
  11. Which is the most widely used database software in the world?

Brian demonstrated mqcontrol, a command line utility to issue MQTT commands. He first installed Go and added

export PATH=$PATH/usr/local/go/bin

to ~/.profile.

After refreshing ~/.profile with

source ~/.profile

he installed mqcontrol with

go install github.com/albertnis/mqcontrol@latest

and then created mqcontrol.service which David advised should be placed in /etc/systemd/system/mqcontrol.service (where it will override all others).

[Unit]
Description=mqcontrol remote control

[Service]
Type=simple
ExecStart=/home/ubuntu/work/goproj/bin/mqcontrol -i mqclinux -c "shutdown -h now" -t jf/close -h 192.168.42.90:1883

[Install]
WantedBy=multi-user.target
…

The IP is the MQTT broker address.

Start and enable the mqcontrol service

sudo systemctl start mqcontrol
sudo systemctl enable mqcontrol

Arguments used in the mqcontrol command

--help
-c string Command to run when any message received on topic
-h string Address and port of MQTT broker (default "127.0.0.1:1883")
-i string ID to use for this client
-t string Topic to subscribe to (default "computer/command")
-u string Username for MQTT connection
-p string Password for MQTT connection

See https://github.com/albertnis/mqcontrol/blob/master/README.md.

David noted that you can do simple commands in Home Assistant by editing the config file with yaml; this is documented in Home Assistant.

Brian asked about backing up NextCloud, in particular the associated database; after a long and varied discussion of the implications of backing up a database, depending on the type of database, David suggested that best thing was to wait till nothing was happening and then copy the NextCloud directory. John pointed out that, if the database is mysql/mariadb, you can use mysqldump to back the databases up to the NextCloud directory and then back that up.

Brian said that he had wanted to configure Opera Android like Opera Desktop so that it was not rejected by a website; David commented that there are lots of results in Google about changing the user agent in Opera but none of them work and Brian said that he had had no response to his query on the Opera forums. However, we noted this discussion.

There followed an extended discussion between David and Brian on Home Assistant configuration, including how to set up the correct permissions for the device which is monitoring your location on behalf of Home Assistant.

David showed off the servos he had ordered which had arrived but which he could not use because the PCA9685 server board had not and also a 3½" disc drive holding dBASE III!

Darren had found that the OU expectations of the Jupyter notebooks exercise had been higher than he had expected; the programming assignment had been to write a program to recognise images. The next unit looks at convolutional neural networks and whether there are alternatives to using them.

For his final year project he is thinking of developing a command line project.

He mentioned that he had read somewhere that Cobol was supposed to be easy but John explained that that was in comparison with Fortran and assembler. There is now a major project to support Cobol on Linux because so many mainframe based systems still use it and David showed off his Cobol book.

Bernard shared a feature of using Redis (which he had described at the 9 October 2017 meeting) whereby someone can subscribe to a key value in order to receive data so that it becomes a subscription service.

Three processes accessing a store

If a publisher writes a log file, for example, to an append only channel, you end up with a continuous stream.

A publisher writing to a store and three processes reading from it

You can also write a program to use the last 20 readings, for example, to create a histogram so that you end up with an average:

# Continuously read a block of 20, print averages of last 20 temperature, humidity.
# suitable for an histogram
import redis, pprint	rconn = redis.Redis(host='localhost', port=6379, db=0)
lastid = "0-0"
while True:
    # read a block of 20, waiting 500 msec if no readings present
    test = rconn.xread({"mystream": lastid}, count=20, block=500)
    # test is list of lists of tuples, [[ b'mystream', [(id, valuedict),...]],...]
    streamresult = test[0][1]
    if not streamresult:
        # no readings, so continue with the while loop again
        continue
    while len(streamresult) <20:
        # not 20 readings yet, waiting for further readings, read one more
        lastid = streamresult[-1][0]
        test = rconn.xread({"mystream": lastid}, count=1, block=500)
        nextresult = test[0][1]
        if not nextresult:
            continue
        # so another reading taken, add it to streamresult
        streamresult.extend(nextresult)
    # streamresult now contains 20 readings, get last id for the next 20
    lastid = streamresult[-1][0]
    average_temperature_in_block = sum(float(item[1][b"temperature"].decode("utf-8")) for item in streamresult) / 20
    average_humidity_in_block = sum(float(item[1][b"humidity"].decode("utf-8")) for item in streamresult) / 20
    print(round(average_temperature_in_block,2), round(average_humidity_in_block,2))

A publisher writing a log file, for example

You can extend this by creating consumer groups which receive unique input, allowing data to be split across different tasks and for another process to take up a task if one fails.

Three consumer processes taking unique data from a store supplied by a publisher

He also mentioned that, when he installed Linux Mint, his Samba share didn't work because the latest version of Samba stops the older version of the protocol from working for security reasons.

So edited /etc/samba/smb.conf to add the lines:

## added by bernie
client min protocol = NT1

because his BT router uses it.

He noted that Snaps are disabled in Linux Mint for the reasons set out in this blog.

Brian commented that he uses CIFS to do same as Samba with

### //server/Downloads
/home/brian/Downloads cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,_netdev,dir_mode=0777 0 0

John shared the page in the Linux Foundation Annual Report showing that Linux kernel support only accounted for 3.4% of expenditure while over 50% went on project support, illustrating the magnitude of the changes over the past 30 years.

Page showing revenue and expenditure for 2021

David commented that that was 3.4% of a very large turnover.

Answers to the quiz

  1. Minix
  2. Slackware — first issued 17 July 1993
  3. Intel — they referred customers to Michael Tiemann who set up Cygnus Support — later RedHat
  4. Deborah and Ian Murdoch
  5. DEC Alpha — in the process he made it possible to support any architecture, not just Intel chips
  6. StarOffice — which later became OpenOffice from which LibreOffice was forked
  7. Because the KDE desktop used the non-free Qt toolkit at the time
  8. 20 October 2004 — Warty Warthog
  9. Git and Subsurface — a scuba-diving program
  10. Java initially implemented via the Dalvik VM and now by Android Runtime
  11. SQLite — because it is used in Android smartphones, it displaced mysql/mariadb from the top spot.