Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Category Archives: RHEL

How to get the active title of an X program

I have scripts that will utilise the SFDC case number, but why type it manually when the computer can do it?

Firstly, you need to have xdotool installed, for RHEL or CentOS Stream, it is in EPEL. I have tried xprop and xwininfo, but they do not accept search with WM_Class

Secondly, get the WM_Class of the X program, usually it is just the program name. If you are unsure, open that X program, then run xprog and click at the X program, then search WM_CLASS amongst the output.

Thirdly, for X program that has multiple tabs, make sure you activate the tab you want.

Now, to get the active title of firefox:

for i in $(xdotool search --onlyvisible --class firefox); do xdotool getwindowname $i; done

Two titles will be shown like:

Firefox
The actual title

For me, I am only interest in the number which are in the beginning of the title, so my command is:

for i in $(xdotool search --onlyvisible --class firefox); do xdotool getwindowname $i; done | sed -rne '/^[0-9]+/ s/^([0-9]+).*$/\1/p'

Barrier/Synergy installation on EL8

I have packaged barrier and synergy a while ago. A user stated that he cannot install it because it misses dependency: avahi-compat-libdns_sd

For RHEL 8, it is in channel codeready-builder-for-rhel-8-x86_64-rpms

To enable it, runs
subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms

For CentOS Stream 8, it is in repository powertools

To enable it, runs
sudo yum-config-manager --enablerepo powertools

Barrier (Synergy) with Wacom Intuos BT M

I am looking for a more ergonomic pointing device. Thus, I borrow my daughter’s Wacom Intuos BT M drawing tablet a try.

Fedora 33 Gnome seems to recognize it out of the box, and the gnome-control-center Wacom interface show it properly. With RHEL 8, it also works as a mouse, but for Gnome to see it, I needed to install the following:

yum -y install libwacom

I mainly use KDE, so I also install

yum -y install kcm_wacomtablet

Gnome did not have the UI to bind the tablet button to mouse button like Mouse button 4 (Scroll Up), nor does it handle key combo binding properly. For example, Ctrl-Win-Left is recognized as Primary-Super-Hyper-Left; KDE, however, does support Mouse button 4~7 so I bind inner left tablet button as button 5 and inner right tablet button as button 4.

I use barrier, a keyboard/mouse sharing utility intensively. So I would also like to see how barrier handles Wacom. Unfortunately, with absolute position mode (the default), the pointer insisted it needed to be in the left edge of the client, I need to use barrier switchInDirection keyboard short keyboard to get away.

I also tried related position mode which make the tablet work more like a giant touchpad. It kinda of work, as the pointer in client act normally. However, that mode is very unpleasant to use, as I need to fully away the distant between stylus and tablet. Basically:

State 1: Stylus touch tablet: Mouse Left button click
State 2: Stylus hover tablet: Mouse move
State 3: Stylus leave tablet: Mouse No action

Switching between State 2 and State 3 is required for related position to work, that is unpleasant.

I tried USB on server, and BT on client as well, but Intuos only support single connection, that is, you have to disconnect USB to use BT, so no single-button-toggle target computers. 😦

Verdict: I would not a recommended Wacom over Barrier/Synergy setup, unless You are OK with relative position mode.

Build in epel8 branch with fedpkg

This article assumes you have commit right to the package, but you don’t have the epel8 branch in https://src.fedoraproject.org/rpms/YourPackage

  1. PKG=<YourPackage>
  2. fedpkg clone $PKG # if you have not done this
  3. cd $PKG # if you have not done this
  4. git branch epel8
  5. # Make the branch work with epel8
  6. git commit
  7. git push –set-upstream origin epel8
  8. fedpkg build
  9. Go to bodhi and create -> New update

Enjoy!

HOWTO: sign dkms kernel module for UEFI secure boot

If you are stuck with UEFI secure boot, and desperately need to build and install a custom kernel module, then you need to know how to sign your kernel module.

To sign a dkms custom kernel, please refer my Git repository: dkms-module-util

Debugging Customizable Kickstart File

Kickstart file automates the installation Linux system. It does not provide a convenient way to pass parameters. Luckily,  passing kernel parameters to %pre installation section works. This method requires you to write your kickstart generation script in %pre section, then in the command section, you call the generated kickstart file.

Unfortunately, this mean it is more likely to fail if the parameters are not correct. How to debug? If you can at lease reach the installer, this document may point you direction.

1. Get the shell access

After anaconda the installer starts,  there are several console tabs, the ones that are useful are:

  • main: the main information screen (Alt-F1 or Ctrl-Alt-F1)
  • Shell: the shell access (Alt-F2 or Ctrl-Alt-F2)
  • GUI: show the install progress if graphical mode is not disabled (Alt-F6 or Ctrl-Alt-F6)

For now, shell access is the focus. Switch to Shell tab by pressing Alt-F2 or Crt-Alt-F2.

2. Inspect parameters by looking at /proc/cmdfile

Just cat /proc/cmdfile to inspect whether the parameters looks right. Personally, I do not want to write complex parser, thus I use quote_plus() from python to encode tricky characters like space, line feed, $ and so on.

3. Inspect the generated scripts and log files

The first thing to check is generated kickstart file. Then check following interesting files in /tmp

  • ks-script-XXX: The script in  section %pre  will be here. Inspect it, and even run it to see how it works or not
  • *.log: various of log files

Enjoy the debugging. 🙂

Solved: nginx module incompatible

I encountered when I run nginx -t:

nginx: [emerg] module
"/usr/lib64/nginx/modules/ngx_http_auth_spnego_module.so"
version x instead of y in 
/usr/share/nginx/modules/mod-spnego-http-auth-nginx-module.conf:1

It indicated that the module version is incompatible.
If nginx was installed using yum or dnf, use following command to set the version:

yum downgrade nginx{,-all-modules,-filesystem,-mod-*}-[version]-[release]

Install Google-Chrome in OpenStack RHEL 7 instances

We have automated tests that require runnable Google Chrome. Yet the Google Chrome kept crashing.

The first encountered is:

libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.

This one is easy, install mesa-dri-drivers solved this.

Then cames:

ERROR:sandbox_linux.cc(338)] : InitializeSandbox() called with multiple threads in process gpu-process

My initial guess was SELinux, but journalctl returns nothing about it. After a few hours, I thought, how about firefox? Maybe it helps to set the SELinux and install the missing dependencies? And… Tada, both Firefox and Google Chrome worked. Eventually, I dug out that Google Chrome requires fonts to works. Specifically, liberation-fonts-common and liberation-sans-fonts.

To sum up, following command worked for me:

sudo yum -y install mesa-dri-drivers liberation-fonts-common liberation-sans-fonts

Update for ChromeDriver user

If you are also use ChromeDriver. Be aware that ChromeDriver 2.31 and up requires libc.so.6(GLIBC_2.18), yet RHEL 7 only provide libc.so.6(GLIBC_2.17)

systemd: remember to keep the daemons alive

My sinopia daemon refused to start. After dig out the journal, I found that ExecStop run straight after ExecStart, what the…

After some research, I found that for daemons, or any other program that put themselves at the background, systemd thought they are stopped, thus stop the service for you. To prevent this, you need following in your systemd service file:

[Service]
...
RemainAfterExit=yes

so your daemons can live happily ever after.

The END

nodejs/npm yum repo for EL7

The nodejs and npm in EL7 is too old, so I borrowed the  to latest nodejs spec from  rawhide. Long story short, the result is at:

https://copr.fedorainfracloud.org/coprs/dchen/nodejs/

Please read the disclaimer and do follow the installation instruction if you choose to proceed. I don’t usually put the disclaimer like that but you need to know that:

  1. The build dependency of nodejs include openssl-1.0.2, but EL7 only shipped with 1.0.1, yet nodejs can run with openssl-1.0.1.
  2. openssl-libs is an important package, without it,  yum, curl and rpm URL install won’t work, so restore it is a bit tricky. The instruction is, however, written in the copr page.

Longer story:

To build this copr, following dependencies need to go in as well:

  1. libuv
  2. crypto-policies
  3. openssl-1.0.2

libuv is piece of cake. But crypto-policies and openssl bring the worst packager nightmare: circular dependency. After F23, crypto-policies require openssl-devel to build, yet openssl require crypto-policies to run.

I eventually dug out crypto-policies from F21 and built it, thus broke the circular dependency and finished the build.