batzconverter – A multiple timezone converter

I do write a lot of scripts to automate my day to day workflow, some of them I just wrote for 3h to save me 5mn time only once and some others I write in about 5mn but save me hours and hour of productivity.

The script showed today, that I am proud of because of its usefulness and probably not of its code, is called “batzconverter“. and available on github. What the script is trying to solve is when you work with your team spread around 3/4 timezones, how do you schedule a meeting easily.

It’s a ~200 lines simple shell script that leverage onto the very powerful GNU date

In its most simple form when you type the command batz you are getting this :

This is showing all timezone (which you can configure) at current time, with some easily identified emojis. The 🏠 emoji on the right is to show the location of the user.

But you can do way more, let’s say you want to show all timezone for tomorrow 13h00 meeting :

It will just do that and show it.

Same goes for a specific date :

You can do some extra stuff, like adding quickly another timezone that isn’t configured :

Or give another timezone as the base for conversion, the airplane emoji ✈️ here is to let know that you showing another target timezone :

easy peasy to use, no frills, no bells just usefulness…

There is another flag called “-j” to allow you to output to json, it was implemented for being able to plug into the awesome alfredapps on osx as a workflow :

But it doesn’t have to be for Alfred, the json outut can be used for any other integrations.

Configuration is pretty simple you just need to configure the timezone you would like to have in a file located ~/.config and the emojis associated with it (cause visuals are important! insert rolled eyes emoji here).

Head up on github chmouel/batzconverter to learn how to install and configure it, and feel free to let me know about suggestions or issues you have using it.

Building packages for multiple distros on launchpad with docker

I have been trying to build some packages for the ubuntu distros for a new program I have released, gnome-next-meeting-applet

In short, it what quite painful! if you are quite new to the launchpad and debian packaging ways (which I wasn’t and yet It took me some time to figure out) you can get quite lost. I got to say that the fedora copr experience is much smoother. After a couple of frustrated google and stackoverflow searches and multiple tries I finally figured out a script that builds and upload properly to launchpad via docker to make it available to my users.

  1. The first rule of uploading to launchpad it’s to properly setup your GPG key on your account making sure it match what you have locally.
  2. The second rule is making sure the new upload you make increase onto the precedent uloaded version or it will be rejected.
  3. The third rule is to be patient or work on week-end, because the queue can be quite slow.

Now the magic is happening in this script :

We have a Dockerfile with all the dependencies we need for building the package in this file :

When we launch the script in the main loop we modify the FROM to go to the distro docker tag targeted (here I have LTS and ROLLING) and we start the container build.

When it’s done we mount our current source as a volume inside the container and mount our ~/.gnupg to the build user gnupg inside the container.

With dch we increase the targeted distro version and we add as well after the release number the distro target after the “~” like this “0.1.0-1~focal1”.

We finish the upload with dput and launchpad *should* then send you an email it was accepted.

After waiting a bit your package should be built for the multiple distribution.

Building RPM with Docker images


For an internal project at work I have been thinking about more how to generate RPMs out of our CI. I wanted to have them produced as artifacts of the build so I can test how if they can be installed and properly working with some smoketests.

Since we are using Docker for most of the things in our CI, I have been thinking about more about how to do that with docker images and RPM.

Ideally what I would love to have from RPM is to be able to integrate with Docker so when you build your RPM you are building in a docker images. Basically the %prep section will be spined-up in a special docker images and the rpm output would be back to the host.

The advantages outside of making sure you are building your RPMs in a confined and reproducible enthronement is that you would be able to say from the same rpm build that I want to build the RPMs for centos/fedora/rhel/etc.. in whatever flavours.

I am sure there is some workaround way to do that with chroot and such but it would be nice if this mechanism is built-in inside RPM (be it an abstracted system to do that as chroot/docker or whatever container technology).

Since we are not there yet, I have ended-up just the straightforward way of constructing an image with my build dependences.

It’s a python project which use PBR for generating the version so I have to generate first a tarball in my build directory and get the generated version.

I modify the spec file with that version and start to build the image with the new tarball and new spec file.

I run the image and mount a volume to a local directory on the host and start running the image which run the script in the container.

The script is pretty straightforward, it builds the rpm and copy them to the volume directory as root (since there is no other way) so they can be copied from the host to the artifact output directory.

I could have not copying and uploading to a object storage system (like Swift obviously) but since I needed to be available in the CI I ended-up up with the local file copy system.

Here is my scripts, in SPECS/project.spec and SOURCES/* there is the spec and sources/patches as a standard rpm, the only thing is to make sure to use a %define _version VERSION and use that macro for Version in your spec file.

The main which get run from the CI

The DockerFile which try to be optimised a bit for Docker caching :

and the script that gets run inside the container :

It probably would not fit straight to your environement but at least that may get you the idea.

Howto use backtrack4 from hard disk with Grub2

If you want to boot backtrack4 from time to time on your Linux desktop/laptop but don’t want to carry it on a USB drive (or CDROM) on you then this guide may help.

I am using Debian unstable on my laptop but I am sure you can adapt it to anything you want. I am using another partition (/dev/sda6) as my backtrack partition but it’s possible to copy the full thing in / as well on your main partition.

Download backtrack4 from backtrack website :

  • mount the iso image locally :

sudo mount -o loop bt4-final.iso /mnt

  • copy the content of the iso to the root of the chosen partition (mounted in /media/part6 for me) :

cd /mnt;sudo rsync –progress -avu * /media/part6/

  • Configure grub :

sudo su –
cat < /etc/grub.d/50_Backtrack
exec tail -n +3 $0
menuentry “Backtrack” {
linux (hd0,6)/boot/vmlinuz BOOT=casper boot=casper nopersistent rw quiet vga=0x317
initrd (hd0,6)/boot/initrd.gz
chmod +x /etc/grub.d/50_Backtrack

  • Update grub

sudo update-grub

And you should be able to boot the Backtrack menu, make sure this point to the right partition for me it’s (hd0,6) because my backtrack copied CD is on /dev/sda6 but your mileage may differ.

XMPP notification for irssi running in a screen on a remote host

Like a lot of people I have my irssi on a server in a screen. This has
been working great so far but my only concerns are the notifications
on the desktop when something happening.

Over the time I have found some different solution with mitigated
results for me :

– Use fanotify script with the libnotify-bin and SSH like mentioned here.

– Setup your irssi (or other) as irc proxy bouncer and connect with
your desktop client (like xchat) to get notification.

The fanotify is kind of very hacky on a laptop with intermittent
connection and having a cron doing a ssh every minutes or so is not
ideal, not talking about no passphrase ssh key or having to snoop the
SSH_AGENT variable to connect without password.

The via proxy method is not my thing and I don’t feel like having
xchat open all the time just for it and I anyway usually forget to
launch it.

My solution is to have a plugin for irssi notify me via XMPP if there
is a direct message addressed to me. I usually get my pidgin or gmail
alway open and if i don’t since it goes to a gmail account I got gmail
sending me an email about it.

You can find all the information about the install and configuration
here :

Vmware vmplayer and kernel 2.6.32

So you have a shiny new linux-2.6.32 kernel installed but your VMPlayer does not work anymore since the vmnet module does not compile by throwing this error :

CC [M] /tmp/vmware-root/modules/vmnet-only/vnetEvent.o
CC [M] /tmp/vmware-root/modules/vmnet-only/vnetUserListener.o
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c: In function ‘VNetUserListenerEventHandler’:
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:240: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:240: error: (Each undeclared identifier is reported only once
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:240: error: for each function it appears in.)
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c: In function ‘VNetUserListenerRead’:
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:282: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:282: error: implicit declaration of function ‘signal_pending’
/tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:282: error: implicit declaration of function ‘schedule’
make[2]: *** [/tmp/vmware-root/modules/vmnet-only/vnetUserListener.o] Error 1
make[1]: *** [_module_/tmp/vmware-root/modules/vmnet-only] Error 2
make[1]: Leaving directory `/opt/temp/linux-2.6.32′
make: *** [vmnet.ko] Error 2

Just do the following to fix it :

make sure first you have installed the latest vmplayer (VMware-Player-3.0.0-203739.i386.bundle) at this time for me.

  • cd /tmp
  • tar xf /usr/lib/vmware/modules/source/vmnet.tar
  • cd vmnet-only
  • vim vnetUserListener.c
  • go to line 37 (after the last include)
  • add this line #include “compat_sched.h”
  • exit your editor
  • cd /tmp
  • sudo tar cf /usr/lib/vmware/modules/source/vmnet.tar vmnet-only
  • restart vmplayer

When recompiling the kernel module it should get it built properly and working it seems…..

Toshiba Regza 32AV615DB blank screen HDMI Linux

I have this nice Toshiba TV which is connected to a small Linux box which act as a media player. I have been some issue lately the things works fine under the 1920×1800 resolution most of the time. But once in a while I get a blank screen and the nvidia driver telling me this :

(II) Dec 03 17:00:19 NVIDIA(0): “nvidia-auto-select”
(II) Dec 03 17:00:19 NVIDIA(0): Virtual screen size determined to be 640 x 480
(WW) Dec 03 17:00:19 NVIDIA(0): Unable to get display device CRT-0’s EDID; cannot compute DPI
(WW) Dec 03 17:00:19 NVIDIA(0): from CRT-0’s EDID.
(==) Dec 03 17:00:19 NVIDIA(0): DPI set to (75, 75); computed from built-in default
(==) Dec 03 17:00:19 NVIDIA(0): Enabling 32-bit ARGB GLX visuals.
(–) Depth 24 pixmap format is 32 bpp

Spend a long time trying to debug the thing by the software but it seems that the TV has some kind of trouble and if I switch it to another HDMI connection it does detect fine which I do at about every week… not a biggie but still annoying.

Nokia N95 bluetooth teethering with T-Mobile under Linux and Delll Latitude D630

Spent a bit of time to configure my Nokia mobile to teethering wih my Linux and T-Mobile. Here is some steps that may help the others :

  • If you don’t have that blue bluetooth led switched on on your Dell Latitude D630 Laptop you have to enable it. I haven’t find any way to do that via the Linux Kernel module but with Windows under Vmware Player (3.0) enabling Bluetooth and installing the driver (manually not via the setup.exe) enabled bluetooth.
  • Switched on bluetooth on the Phone and attached to the laptop via gnome bluetooth applet thingy.
  • Get my phone device number from hcitool scan.
  • And did this (as root) :

cat </etc/bluetooth/rfcomm.conf
# RFCOMM configuration file.

rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device

# RFCOMM channel for the connection
channel 4;

# Description of the connection
comment “Nokia N95”;

/etc/init.d/bluetooth restart

cat </etc/ppp/chat-tmobile
SAY ‘Calling t-mobile…\n’
“” ‘ATZ’
OK ‘ATE0V1&D2&C1S0=0+IFC=2,2’
SAY ‘Modem reset.\n’
SAY ‘Setting APN…’
OK ‘AT+cgdcont=1,”IP”,””‘
SAY ‘APN set\n’
SAY ‘Dialling…\n’
OK ‘ATDT*99#’

cat </etc/ppp/peers/t-mobile
idle 7200
user “user”
password “pass”
ipcp-restart 10
lcp-echo-interval 65535
lcp-echo-failure 10
lcp-max-configure 10
connect “/usr/sbin/chat -v -f /etc/ppp/chat-tmobile”

Under Debian distros you can enable the connection with the command ‘pon t-mobile’ or you for the others can do via the manual way with the command ‘pppd call t-mobile’.