Joseph Zikusooka (ZIK)

Linux Systems Engineer specializing in open source software technologies | Very experienced in building and configuring UNIX/Linux systems and servers. Passionate about developing software applications and hardware for the smart home | Currently serving as technologist at Jambula Labs and the project leader at JambulaTV, a smart home automation and entertainment platform - https://jambulatv.com | This blog focuses on the following areas: Linux How-Tos and Tutorials ::: IT Security News ::: Free and Libre Open Source Software ::: Smart Home Software ::: Digital Innovations in East Africa https://mastodon.social/@jzik | https://github.com/zikusooka

Author : Joseph Zikusooka

I am a software engineer and developer specializing in open source software. I have a solid experience building and configuring UNIX/Linux systems and servers. I am passionate about developing software applications and hardware for the smart home I am currently serving as the CEO of Jambula Labs and the project leader at JambulaTV, a smart home automation

How to Migrate to Digital TV in Uganda – A consumer’s Experience

Are you still puzzled by Digital TV Migration? Are you wondering how to start watching Free-to-Air DTV broadcasts in your area? Help is here inform of a consumer’s experience. Julian Mwine has put together a seven minute video, explaining the process involved in migrating to Digital TV in Uganda. Keep in mind, despite the deadline being 4 months away, we are still in early stages.

Connect to 3G networks in Uganda using the Linux command line

If you are a Linux user living in Uganda and use 3G internet, you may want to try out my tools to connect to the Internet. These are a couple of scripts I created a while back, however, I’ve now updated them to allow for the following:

  • You can now connect to Airtel, Orange/Africell, MTN, UTL, and Smart telecom.
  • I have added the capability to use your PC (or device such as a raspberry Pi) as a router, this way several devices can access the Internet using one 3g dongle. You can create a MiFI of sorts if you’re inclined to.
  • Query your modems for: EMEI, Serial, IMSI numbers, Lock status, Model/firmware version, etc.
  • A few BUG fixes and script clean ups.

Want to try it out? Visit my Github repository

How to stream FM Radio using the Command Line in Linux

With all the advancements in IT, one piece of technology has persisted and seems not ready to die yet: FM radio. Unlike its companion AM, FM radio continues to be the primary source of information and entertainment. For example, in the United States, FM radio is still alive, and is used by many as a discovery medium. Most people especially teenagers will tell you that they first heard a song on terrestrial FM radio, before they went on to streaming sites such as YouTube, Spotify etc. In Uganda, like elsewhere in Africa, expect traditional FM radio to continue being king of information. Our limited Internet infrastructure is still very limited to a small section of the population, speeds are still horrible, so on-line radio is still not an option for many.

As I work on my upcoming digital product, I debated a lot about whether to include FM radio as a feature on this device. With all the above said, there was no doubt, FM radio would quickly become one of the most requested for features. So I got down to playing, recording, and streaming Live FM radio using the Linux command line. The cool bit is that you can stream a live FM radio show to all your devices in the house or office. No need for you to buy a radio.

What you need:

a) Analog Video for Linux (V4L2) FM radio tuner. You can either use a USB stick or PCI-E based card.

b) Linux distribution – Am using Fedora 20. But any Linux distro will work, although you will need to adjust the install commands where necessary.

Available Linux CLI tools:

There are a whole lot of GUI based applications that you can use to play radio in Linux, For example Gnomeradio, Kradio, gradio etc. However, using the command line gives you much more flexibility, as the following commands illustrate. You can control an FM radio tuner using CLI tools like MPlayer (which is installed on most Linux distros), ivtv-radio, and fmtools. In this ‘how to,’ I use the latter, fmtools, which comes with a set of tools (fm and fmscan) for controlling V4l2 based tuners.

Installation:

1. Install fmtools

yum install fmtools (On Red-Hat based Distros such as Fedora, CentOS)

2. Install SoX

yum install sox (On Red-Hat based Distros such as Fedora, CentOS)

3. Install VLC

yum install vlc (On Red-Hat based Distros such as Fedora, CentOS)

FM Radio Commands

The basic arguments for the fm command line tool are:

fm -d [device] -T [time] [freq] [on|off] [percentage]

-d The radio device created by your USB or PCI based tuner
-T The duration of play
-q quiet | No verbose
[Freq] The radio channel
[on|off] Turn on or mute radio
[Volume] The desired volume

Tune and play FM 91.3

fm -q -d /dev/radio0 -T forever 91.3 100%

Mute:

fm -q -d /dev/radio0 off

Unmute:

fm -q -d /dev/radio0 on

Recording FM Radio

To record FM radio, use parec a utility that is packaged with pulseaudio, the default sound subsystem on most Linux distros.

1. First tune to the desired radio station as shown above.

2. Capture the audio:

parec -d alsa_output.pci-0000_01_01.0.analog-stereo.monitor | sox -t raw -r 43000 -e signed -L -b 16 -c 2 - /var/tmp/fmradio.wav

NOTE: You will need to change the variable -d i.e. output pulse device for your system. To find yours, just run the command:

pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -1

The recording will be stored at /var/tmp/fmradio.wav. You can change that to another location if you wish.

Stream FM Radio to other PCs or devices (such as smart phones)

Start the capture process as shown above, and proceed immediately to the stream command below:

vlc -I dummy -I http --daemon --no-video --no-sout-display-video --verbose 2 /var/tmp/fmradio.wav --sout #duplicate{dst=standard{access=http,mux=asf{title='JambulaRadio',author=FM-91.3-Radio-Kampala(Uganda),copyright=2015-2016-Joseph-Zikusooka-All-rights-reserved,comment=Broadcasting-Live-from-Kampala-Uganda,rating=PG14},dst=192.168.0.10:8090},dst=standard{access=http,mux=asf{title='FM-Radio',author=FM-91.3-Radio-Kampala(Uganda),copyright=2015-2016-Joseph-Zikusooka-All-rights-reserved,comment=Broadcasting-Live-from-Kampala-Uganda,rating=PG14},dst=172.16.0.1:8080}"}

NOTE: Here, I’m streaming on both wired and wireless LAN, and my machine IP addresses are 192.168.0.10, and 172.16.0.1 respectively. The http stream port is 8080. Change these to suit your environment.

If you are using a wired connection, use VLC on your client PC or mobile phone to access the stream as follows:

vlc http://192.168.0.10:8080

If on Wireless, use vlc on your client PC or mobile phone to access the stream as follows:

vlc http://172.16.0.1:8080

Enjoy!

Uganda’s digital TV Migration – A status update

With only 5 months left before the international deadline for analogue TV switch off, here is where Uganda stands in the move from analogue to digital TV broadcasting.

As of January 2015, the following areas have access to the Over-the-Air digital TV signal: Kampala, Entebbe, Bombo, and Mityana. Basically only a small part of central Uganda is covered. Also DVB-T tuner tests indicate that depending on your location, you may still not be able to access the DTV signal which is being transmitted from Kololo. For example in areas East of Naalya an Outdoor Antenna may be required.

Also, only a few TV stations are currently broadcasting in Digital TV. For example,
NTV Uganda, Bukedde TV 1, WBS TV, Urban TV, UBC etc. For a specific status on each of the local TV channels, take a look at the Digital TV Migration Status page

With regards to equipment, some merchants in Kampala have already started to sell analogue-to-digital TV converter boxes, which is what the majority of household with require. However, at prices of up to 150,000/=, this might still be prohibitive for the majority of homes in the country.

With the the looming deadline, Uganda Communications Commission (UCC), has promised to start rolling out Digital transmission to other areas of Uganda. We look forward to that.

Getting started with Docker on Linux

Docker containers are all the rage these days. However, if you’ve used Linux for a while you’ve come across LXC. For FreeBSD users, docker containers will remind you of jails. Docker is essentially the same, but with a better tool chain that makes it easy to build system images and move them around different environments. Docker is also lightweight and very fast when compared to LXC for example.

With traditional office servers increasingly being moved to the cloud, it is easy to see why docker is popular. The ability to deploy and scale easily, makes docker a must-learn tool for IT administrators.

Here are a few notes to get you started with docker. For a detailed instructions, see the official docker user guide.

Getting started with docker

Install docker
yum install docker-io
(On Red Hat based systems)

Start the docker service
systemctl start docker

Pull docker image from the repository
docker pull fedora
(Ensure your Internet speed can handle the size of this image)

List all images available
docker images

Run docker image (interactive mode)
docker run -i -t fedora /bin/bash
(Type exit, to get out and leave container running)

Show containers current running
docker ps

To reconnect to the docker instance after exiting:
docker attach [CONTAINER ID]

To start an existing docker container:
docker start [CONTAINER ID]

To stop a docker container
docker stop

How to ship your first container
Reconnect to the container as shown above.

Show all the changes that were made since initial creation
docker diff [CONTAINER ID]

Commit your changes
docker commit [CONTAINER ID] [TAG]

Then to see the newly created image, run
docker images

You can now share your image. Please note that for the public docker repository, you need to follow the proper naming conventions when picking a tag for your image. Then push the image as follows:
docker push [USERNAME]/[TAG]

As you begin to create images using docker, you may want to read documentation on dockerfiles and how to use them to quickly deploy your containers.

Toggle between two or more Digital TV channels that are simultaneously playing

With the advent of Over-the-Air (OTA) Digital TV in Uganda, I have found myself watching two or more TV channels simultaneously. This is true especially during the 9 O’clock hour when most local TV stations in Uganda broadcast the evening news (OK, now you know: I am a news junkie).

While recording TV shows solves this itch as is the case with an upcoming media product I have been working on, it is still great to watch the news live. You could manually mute a currently audible TV channel, and unmute the next desired one – but that’s no fun.

A while back, I whipped up a script that helps you toggle between all the available audio sources you are listening to. It essentially switches between all the available sound sinks. In my case, I use VLC to watch OTA digital channels with podcasts on some occasions. What is neat, is that you can bind this script to any key on your keyboard, remote, or even Bluetooth device.

If you are using a Linux based device and you are interested, I am making this tool available at: my Github repository

Customize your Linux desktop using the command line

With most Linux distros now using GNOME 3.10+, here are a few commands on changing the look and feel of your desktop using gsettings. Other CLI methods exist such as the popular GNOME tweak tool and Dconf.

Add apps to favorites bar
$ gsettings set org.gnome.shell favorite-apps "['google-chrome.desktop', 'evolution.desktop', 'nautilus.desktop', 'libreoffice-writer.desktop', 'libreoffice-calc.desktop', 'firefox.desktop', 'gnome-terminal.desktop', 'vlc.desktop', 'jitsi.desktop', 'gedit.desktop', 'gcalctool.desktop']"

Change show date and clock format
$ gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.interface clock-format '12h'

Change background picture
$ gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/gnome/Sandstone.jpg'

Those are just but a few of the settings available for you to tweak. To see all of them, type:
$ gsettings list-keys .

Easily convert from VirtualBox to KVM in Linux

KVM
I have been converting some of my old VirtualBox images to KVM, which is the virtualization standard in Linux.

Its really easy, although, if you run into booting issues of the converted image, the last tip here will save you some time.

To convert from VirtualBox to KVM, look for your VDI images.

qemu-img convert -f vdi -O qcow2 [VBOX-IMAGE.vdi] [KVM-IMAGE.qcow2]

e.g. qemu-img convert -f vdi -O qcow2 FreeBSD-7.2.vdi FreeBSD-7.2.qcow2

You can now import the converted image using virt-manager or the CLI tool virt-install.

In Virtual Machine Manager, go to Disk 1 >> Advanced options and change ‘Storage format’ to qcow2.

This prevents boot errors like ‘boot failed: not a bootable disk’ when you launch the VM.

WebRTC – Why Skype will become less dominant

If you know me, then you know that am not much of a Skype fan. If I have to make Internet based calls, my go to app is Jitsi, which uses my own managed Asterisk server as its proxy. Asterisk allows for all types of calls including SIP-to-SIP, and international calls terminated by regular phones.

But that’s me. For most people Skype is the dominant app for Internet calls. So when people ask me whether I am on Skype, my answer in most cases is ambivalent. While I have a Skype ID, I rarely use it. Why you ask? It is a long story. Really – its a long story. Bottom line, I no longer use Microsoft software, and most of my work is done using open source software.

It is important to note that Skype data and calls are handled via proprietary channels and routed to servers we really don’t know about. Also, keep in mind that while it might not matter to you, Skype has become a surveillance tool for many Governments. Take a look at this article. And yes, the NSA is also in on it.

Google Hangouts

The current popular alternative to Skype is Google Hangouts. Hangouts is really good and does a good job when you need to do one-to-one voice and video calls, and even conferencing. The only requirement is that all the participants must be signed into the Google ecosystem. The latter statement kind of points to why, I still have a hard time using Hangouts. What’s the problem, you may ask? Well, for one, you are still tied to Google’s infrastructure. Just like the Skype situation, all calls go via Google’s servers. Also, Google has a very terrible record of axing services – Take the example of Google Reader, Google Buzz/Wave, Google Voice’s XMPP implementation to name but a few.

Open source VoIP software

Currently, there’s no open source software that perfectly replaces Skype. OK, may be it exists, but may not be as simple to use as Skype. In the open source world, traditionally, you’d use PBX systems such as Asterisk (See my previous article on setting up asterisk). These servers would bridge internal and external calls.

The problem though is that most networks are heavily militarized (i.e. firewalls) – Most block the commonly used Voice over IP (VoIP) protocol of SIP. So if I have to setup a video or voice conference for four company users, assuming two are in Nairobi, and the other two are in Kampala, I would have to ensure that the company’s PBX server they will use to connect is on a network that has SIP ports open. For a techie, this is not hard to setup, as you only need to ensure that port forwarding for VoIP services is enabled. However, this process tends to be cumbersome.

The other hurdle is that the four users each have to install a SIP client on their PCs (in case they are not using hard phones). Skype solves this issue, by simply having users install from a central repository, and then users sign up all in one place. In the open source world, its not as simple as that, as users need to first pick a SIP client. Many examples exist, but my favorites are Jitsi and Linphone. Then, the server administrator needs to provide the users with a username/password or extension. Again, for the savvy, there are always ways to automate and make this simple, but not for the typical user.

I believe, this is why Skype has been the go to place for VoIP services. However, things are about to change with the recent introduction of a technology known as WebRTC

WebRTC – Real-Time communications

WebRTC

WebRTC, is a free and open source project that allows real time communication using web browsers. That’s right – You can now make calls using your web browser! It enables peer to peer audio, video and data communications between web browsers. Recent versions of Chrome, Firefox, and Opera now support WebRTC.

WebRTC solves the challenges of open platforms I mentioned above by allowing the web browser to act as a sip client during video and voice calls. In fact, the original server is needed only during the initialization stage, thereafter, the client browsers, will communicate with each other directly.
So here’s how it would work: My four users in Nairobi and Kampala would go to a website URL that I would send to them, and simply sign in and immediately start the conference. No drama, No fuss.

WebRTC, while a very young technology, promises to revolutionize the way we communicate. For one, the communication will no longer rely heavily on middle men.

It is now possible to have ‘Call or Chat with us’ links on web pages allowing for website visitors to directly talk to the web managers. Think of it as a kind of support desk.

WebRTC, also means users do not need to be bothered with installing software or plugins on their PCs or mobile devices in order to chat or talk. Just use the existing web browser where most users already spend most of their time on the Internet.

Of course, Skype will continue to be with us for some time, but the proliferation of mobile platforms will see more and more software vendors turn to WebRTC to do cool things on these devices.

Why SystemD will start your next Linux system

For a long time, the default boot and initialization mechanism in Linux was the System V (SysV) init daemon. Along the way, many Linux distributions have attempted to move away from this primitive form of booting. Why you ask? For one thing, it makes the boot process a lot slower, since processes have to be started one at a time. It is also a nightmare to maintain the scripts that Administrators write to manage these start processes, as each package maintainer or administrator, does ‘their own thing.’

Linux SystemD

 

So Ubuntu, one of the most popular Linux distributions moved to upstart in late 2006, but this init daemon they adopted, was not widely embraced. Debian, OpenSuse, Fedora, and Red Hat at some point in the last five years supported upstart. Red Hat Enterprise Linux (RHEL) version 6 and derivatives such as  CentOS  still use upstart. But all of them are ditching upstart for something better, i.e. SystemD. In fact, the Debian technical committee recently voted and they will switch to SystemD in upcoming releases, leaving Ubuntu no choice but to follow.

It now looks like SystemD will be the default initialization and boot method for Linux systems for many years to come. But what does systemD do different?

What is SystemD?

SystemD, is a system and services manager for Linux that was developed by a team from Red Hat, spearheaded by Lennart Poettering, the creator of pulseaudio, and Avahi. SystemD makes Linux systems boot faster since processes are ran in parallel. Once started, processes are monitored, and restarted if they crash. SystemD also reduces the dependency on shell scripts to do much of the work.

Other systemD features, include a cron-like job scheduler, an integrated login manager, which offers ‘multi-seating’ functions. It also has a new an improved logging mechanism called the journal, that will likely replace syslog, the current logging facility on Linux systems.

Below is some technical information to get you as the administrator started with systemD. Please note that there are several manuals and online resources available that will help you understand systemD, I will mention a few at the end of this post.

How to get started with systemD

SystemD is installed by default on recent versions of Fedora, and Arch Linux. For other distributions like Debian and Ubuntu, you might have to wait a bit for systemd to be packaged as the default init system. It is actually recommended that installation is done by the distribution vendors. But if you are the brave type, you can of course install it from source.

Pick up the source tarball and follow the instructions contained in the README file included with the sources.

After installation is completed, you will need to start converting your old startup scripts to systemD. At this time, only SysV init scripts for commonly used services, have been ported to systemD. So you will need to know how to write a service file for rarely used daemons or for that program you are developing. Below is an example of a systemd service file. By the way, these are what those files in “/etc/init.d” used to be.

How to write a systemD service file

Open up your favorite editor such as vim as follows:
vim /tmp/squid.service Am using squid here as an example, so replace it with the name of your service. Enter the following snippet:

[Unit]
Description=Squid caching proxy
After=syslog.target network.target nss-lookup.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/squid
ExecStartPre=/usr/libexec/squid/cache_swap.sh
ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF
ExecReload=/usr/sbin/squid $SQUID_OPTS -k reconfigure -f $SQUID_CONF
ExecStop=/usr/sbin/squid -k shutdown -f $SQUID_CONF
PIDFile=/var/run/squid.pid

[Install]
WantedBy=multi-user.target

At a minimum, you will need these three sections; unit, service, install.

Unit definitions
Description: A string describing the service and what it does.
After: If service depends on another one, then indicate that it should come after those targets. Notice in my example that one of the pre-requisites for this service is the network service. You will see that often, as most services expect the network to be already running, so always include it.
You can also add ‘Before’ which does the opposite and starts this service before units listed.
Hint: You can read more about unit definitions by calling up the manpage: man systemd.unit

Service definitions
Type: You must always have a type, which can either be forking, simple, oneshot, dbus, or notify. For most daemons, forking should suffice, as it forks the processes by putting them in the background after start.
EnvironmentFile:This is the file which contains the options used by your service daemon. This can be omitted, but can be a life saver occasionally
ExecStartPre: This is the command that is called before the main process – see ExecStart
ExecStart: This is the command that the daemon runs. You can also point to a script on your system e.g. =/bin/sh -c “/usr/sbin/my-cool-script.sh”
ExecStartPost: This is the command that is called after the main process – see ExecStart
ExecReload: This is the command that is called in order to reload the daemon’s configuration file.
ExecStop: This is the command that is used to stop your service.
PIDFile: Enter the file path containing the process ID of your service. SystemD reads this file after startup.
Hint: You can read more about service definitions by calling up the manpage: man systemd.service

Install definitions
This section is optional, but can be used to set the target level
WantedBy: Set a target where this service will be grouped. Like run levels in SysV language.
Hint: You can read more about various special targets by calling up the manpage: man systemd.special

Activating your systemd service

When you are done writing the service file, copy it to: /usr/lib/systemd/system/
cp -v /tmp/squid.service /usr/lib/systemd/system/

You will need reload the systemd daemon:
systemctl --system daemon-reload
In order for the service to start automatically at boot time, enable your systemd service as follows:
systemctl enable squid.service
Now when you want to start, stop, reload or check the status of this service; do the following:

systemctl COMMAND squid.service ; where COMMAND is either {start|stop|reload|status}

This how-to barely scratches the surface. There are lots of neat tricks you can perform with systemD that your old dog SysV and upstart could not. So take the time to learn it.

Resources:
SystemD website: http://www.freedesktop.org/wiki/Software/systemd
Lennart’s Blog: http://0pointer.de/blog(Look for the SystemD series for Administrators)
Mailing List: http://lists.freedesktop.org/archives/systemd-devel
Man pages: systemd- (Use tab completion to see all available man pages)

Scroll to top