New motherboard

For my birthday, I bought myself a new motherboard. The previous motherboard was speedy; but, not stable. I pulled out an ASRock X370 Taichi and put in an MSI X470 Gaming Plus.

I kept everything else the same: RAM, video card, storage. So far, the MSI motherboard is performing admirably.

Three little snags I ran into:

  • Backups were a pain.
  • Sound card appeared to not work (but probably did).
  • Btrfs is not reconfiguration friendly.

I never did get Clonezilla to work as a backup. I’d bought an external USB hard drive from Costco last year I think. No matter how many times I tried to put a partition on it, it would err out. I think this was because the drive had an MBR (Master Boot Record) config on it instead of GPT (GUID Partition Table). Ultimately, I booted off of a GParted live DVD, and wiped the external USB that way. Then created an ext4 partition for the whole 5 terabytes. From there, rebooted back into OpenSuSE and used rsync. Specifically:

su -
mount /dev/sdc1 /mnt
rsync -aAXv /home /mnt

That took a while. But after I got a backup of my home directory, I was free to start taking apart hardware. 🙂

But yeah, I started around 9:00 AM, and only got the good backup going by 11:30 AM. Cryptic error messages are cryptic.

The Taichi motherboard removal actually went reasonably easy.

What did delay me a little bit was that when I first installed the Noctua NF-S12A PWM system fan, I installed it 90° off; the cable from the fan was about a finger’s width too far away from the motherboard connector. Although it was super easy to remove the Noctua – it has rubber posts and grommets instead of screws (which make it super quiet) – putting it back in to the case was slightly difficult. During the initial build, the fan went in first, so using the needle nose pliers to pull on the stretchy polymer posts was easy. But this time, the power supply and motherboard are already in there, and I don’t really want to have to pull all that out for one corner of the fan mounting. Eventually I got it, but it wasn’t easy.

Boot the machine up, and things are looking pretty good. But I have this fear that sound and Linux are enemies, so I go in to YaST and test the sound. The sound tests fail. Following instructions though, SDB:Audio troubleshooting specifically this test:

speaker-test -c2 -l5 -twav

did produce sound! So sound is working after all. It’s just something in YaST the fails to to produce the test sound. Apparently.

All I really know is that I got to the point where I disabled the second sound card (it’s built into the video card), rebooted, and decided to just try Youtube. Youtube worked. I had sound and everything. I’ll call that a win.

HOWEVER, now it’s time to bring in my files for my home directory, from my backup. And I had forgotten to do some manual partition work during the initial install. I had wanted to wipe both /dev/sda and /dev/sdb so that during the initial install, hardware detection would find what is in the MSI X470, with no previous crud from the Taichi motherboard be hanging around.

But I had not bothered to manually change the partitioner to make /dev/sdb the /home directory. I figured I could do that later. I figured wrong.

Under previous systems, it was pretty easy to delete /home on /dev/sda3 and then configure Linux to mount /home on /dev/sdb1 instead.

Btrfs was having none of that. And if I thought the gparted errors about the external USB partitions were cryptic – this took obfuscation a whole new level.

The good news is that I’d already done all the copies to /dev/sdb1 (from the external USB backup on /dev/sdc1 ), so that work wasn’t wasted.

And indeed, it was easier to just wipe /dev/sda and install all over again. This time, during partitioning, I specified the existing /dev/sdb1 to be mounted as /home and Btrfs left it’s grubby mitts off my home directory disk.

Finished the reinstall, deleted the second audio, and et voila – my machine seems almost exactly like it was this morning when I woke up. I almost can’t tell I did a whole motherboard swap out underneath; except so far no spontaneous reboots. 🙂

mech-dump (part of Perl WWW::Mechanize) is incredibly stupid about it's input file name

If the file name it is dumping does not end in:

.html

the mech-dump will spit out an error that the file content is not text/html it is text/plain. And of course, it immediately quits without doing anything helpful.

And then you go and look inside the file, and this is right at the top:

content="text/html"

You ask yourself What the Hell?

It’s a terrible error message; that’s the hell of it. The error message should say “Input file name does not terminate with the string .html”

I use Linux a lot, and in Linux, files do not have to have file extensions in their names. Over in the Windows side, it is expected that a file name has an extension. Windows uses that file name extension to figure out which program should be associated to the file type. But in Linux, the program association data is written inside the file itself.

This has two effects. First, files in Linux don’t need file extensions in their name. Second, you can name a file in Linux to not have the file extension, and the file works anyway.

So, if I’m writing a Perl script on Linux and I want to dump out something I’ve just pulled down from a web server, using WWW::Mechanize, I might be inclined to name the file where I’m dumping this web form to www_mechanize_web_form_dump

And this would be a mistake, because when I later run

mech-dump www_mechanize_web_form_dump

I’m going to get spit at with the message that the file does not contain HTML, it contains only plain text.

It would have saved me a bunch of time, if the error message would have been “mech-dump does not interpret files with names that do not end in .html”

That might seem kind of a silly input file name constraint, but at least the error message wouldn’t be misleading.

Bitnami WordPress Multisite – DNS spoofing

In an earlier post, I said I hope you have pointed your domain name at your static IP address. Well, what if you don’t want to?

The point being that the DNS entry for the domain name currently points to the production WordPress site, and really, I would like to set up this multisite WordPress installation without having to change the public DNS entry.

Also, setting up this, my personal blog, I was using No-IP DNS services. I could update the DNS entry for gerisch.org, and the DNS replicated out almost instantly. It was great. But the other web site I’m working on (the one that got me into WordPress at all), is using Network Solutions for their DNS. They take their good sweet time replicating DNS entries out to the world. I don’t really want to post an update to DNS, wait, dink around with the new site while the production site is down, decide to revert to production, post an update to DNS, wait again while Network Solutions gets around to pointing everyone back to the production web site.

It would just be better if the new web server machine never got away from it’s own self when doing lookups for the domain name it will eventually be.

So I can start the WordPress install from the IP address of the server out on the public Internet. However, WordPress during it’s install, is going to do a DNS lookup, and try to invoke code on the server where the DNS really does resolve. Which isn’t where I am. So I’m going to try to install a fake DNS server on the new server, and have it redirect all calls to the old domain to the new server.

Step the first: install dnsmasq

sudo apt-get install dnsmasq

Next, set up listening on the local host address:

sudo vim /etc/dnsmasq.conf

Find your way to the line #listen-address= and edit it thus:

listen-address=www.gerisch.org

And save and exit

sudo vim /etc/dhcp/dhclient.conf

Find your way to #prepend domain-name-servers www.gerisch.org; and uncomment this line. Save and exit.

And now it gets weird.

The Bitnami / AWS Lightsail images use something called cloud-init : https://cloudinit.readthedocs.io/en/latest/topics/modules.html

So if you were going to try to edit /etc/hosts or /etc/resolv.conf you get warned to not edit them by hand, because they will be replaced on next boot. But they sure as heck don’t tell you where to implement edits. Just don’t do it here.

Turns out there are template files in /etc/cloud/templates that hold the magic.

cd /etc/cloud/templates
sudo cp hosts.debian.tmpl hosts.debian.tmpl.original
sudo vim hosts.debian.tmpl

Now I’m going add a line below www.gerisch.org localhost which will be the IP address I want this machine to go to whenever it tries to resolve the domain name of the production web site

And indeed, if I use dig from an ssh session in the machine, dig reports back the local machine’s address, not the one out on the public Internet

Follow up to xdotool doesn't work nicely

My previous post was that Windows “just works”, and Linux was “good luck with that”. Indeed, I had a deadline, and to get the job done, I used Windows and WinBatch, just got it done. On time. On a laptop. In my car. Yay.

But really, my nice setup is here at home, instead of on the laptop in my car. And my preferred setup is this OpenSuSE box here at home. So, now that the time pressure is lessened, I can spend a little more time, trying to figure it out. The secret is to not use the one-liner feature of xdotool. If you do the one-liner format of xdotool, it composes the command to throw at the window with “XSendEvent”

If you do multiple xdotool commands in order, it composes the commands to throw at the window with “XTEST”

More accurately, if the xdotool command has –window in the line, then XSendEvent is used. If xdotool command has only the “key” command in it, XTEST is used.

Apparently, most programs ignore window commands send with XSendEvent, so xdotool does it’s tool do to X, and the window ignores it.

Yay.

Here is one of the scripts that finally worked. Note I did have to add a time delay in, because otherwise the audio player window wasn’t ready in time for the following key stroke to be input.

!/bin/bash
 WIDLibre=$(/usr/bin/xdotool search --name "LibreOffice Writer")
 WIDAudio=$(/usr/bin/xdotool search --name "Insert Name Of Window of audio player here")
 /usr/bin/xdotool windowactivate $WIDAudio
 /usr/bin/sleep 0.5
 /usr/bin/xdotool key Control_L+comma
 /usr/bin/xdotool windowactivate $WIDLibre

This script sends a comma (with the Control key modifier) to the audio player. In WinBatch, this would be SendKey("^,")

Ctrl+, is the pause / unpause keystroke for the audio player. The other script, uses the left arrow key to rewind the audio. One script each is attached to a couple KDE shortcuts. Each of those keytroke combinations is programmed into a Kinesis Savant Elite2 foot pedal. So the left pedal backtracks the audio a few seconds, and the right pedal pauses / unpauses the audio. Window focus remains in LibreOffice.

To figure out what to use for “Insert Name Of Window of audio player here“, use the command wmctrl -l

One thing to note: the full name of the window (because of the audio player I used) had the length of the audio in it. That time had special characters in it (colons to separate minutes from seconds); so either I would have had to escape them out, or, I just put the first part of the window name in, up to the time / length.

The whole secret to the thing was that this did not work:

/usr/bin/xdotool --window $WIDAudio key Control_L+comma

and this did work:

/usr/bin/xdotool windowactivate $WIDAudio
/usr/bin/xdotool key Control_L+comma

Windows "just works" versus Linux "good luck with that"

I’m trying to do some audio transcription, so that I have text to go along with the audio. Transcription is still quite the labor intensive problem, even here a few months away from 2020. Sure, I can get Amazon to do a basic transcription for very little cost (pennies more than dollars); but, the transcription isn’t very good. Part of the problem is that one of the speakers has a thick Southern accent.

Fine, whatever – I’ll just fix it.

Years ago, I was a “programmer” for an NC Drill. “NC” is the acronym for Numerical Control. So this drill just put holes in circuit board material at numerical X Y coordinates. My job was to digitize the artwork (or at least, line up the crosshairs on digitizer with the pads on the artwork, and then tap a foot pedal. As I spun the dials, the X and Y positions would be counted, and when I hit the foot pedal, the current position was recorded. (Actually, it was punched onto a paper tape).

So I learned that foot pedals are a nice way of interfacing with the computer. Especially with your shoes off. 😉

For this transcription work, I need to be editing a document (with my hands), but I’d like to pause and rewind the audio with foot pedals. I bought a somewhat expensive foot pedal from a company in the Pacific Northwest (Made in USA). It works well.

But what to have it do?

At first, I programmed it to do direct keystrokes: Alt-Tab to switch to the last window, Space to pause, Alt-Tab to switch back.

But this has the drawback that the last two windows I’ve used must be the one’s I need, and it’s terribly inflexible. How about picking an un-used set of keys as shortcuts / hotkeys, and attaching scripts? This way, the script can pick the name of the window from the open list, and go right there no matter if it’s been pushed to the back by something else.

Windows, with WinBatch, it just works.

Linux, with xdotools is a nightmare. Someone said xvkbd is the right way to go, to get around the fact that xdotools doesn’t work. Tried the combo, and now one run of one of the scripts kills off the other script from being able to work. I’ve got both, because xdotools does know now to do a “WinActivate” (to use WinBatch terminology), and it doesn’t appear that xvkbd doesn’t do window management. And it wasn’t written for that, either. But xdotools doesn’t know how to send the Space character to the media player, so I’ve got to mash these two together.

The xdotools people say it’s not their fault; most applications block input. Although somehow the xvkbd people are managing it.

I’ve used xdotools at work, and it does great with mouse clicks; so there’s that. But VLC and other Linux media players (many based on VLC) refuse to use a mouse click as “pause” for the video (where YouTube and Facebook don’t have a chip on their shoulder, and just do what is natural for people).

Anyway, I had a deadline to meet, and Windows actually got the job done.

How to make Ubuntu have a nice bash shell like OpenSuSE

There are two features of OpenSuSE that I love when logging in to the command line, that do not exist in Ubuntu. Problem is, I’m renting web servers from Amazon, and those are Ubuntu. So I log in to them with ssh, and the bash completion features I want are not there. This post will be documentation of how to get back to the settings I want.

Apparently, theses used to be the settings that most Linux distributions came with. But someone somewhere decided they had a better (in my opinion: worse) plan, and the rest of the world didn’t push back. Well, except for OpenSuSE. Since I cut my teeth on SuSE, I grew to really like those features, and badly miss them when I’m on a Ubuntu box.

First up: change the editor to VIM

On these new boxes, the file ~/.bash_profile does not exist. That’s fine; Ubuntu will read it on login if it does exist.

vim ~/.bash_profile

Get into insert mode with <ins>

export EDITOR=vim

Because the presence of .bash_profile breaks .bashrc (used later), add this to .bash_profile:

[ -r $HOME/.bashrc ] && source $HOME/.bashrc

Save and exit VIM with <esc> : w q

Now, if you are looking at a file with “less” and you want to then edit it, you can hit the letter “v” and be editing the file.

I imagine that way back when, “v” was a way to think “VIM”; but once Ubuntu changed it’s default to the nano editor, that doesn’t really map any more. This changes it back.

Second up: alias the change directory command up-one-level to ..

vim ~/.bashrc
/^alias

Move to the bottom line in the list of aliases, and do a “yank”, then a “paste” in VIM:

yy
p

Then get into edit mode by hitting the <ins> key, and modify the pasted command to be this:

alias ..='cd ..'

Get out of insert mode with <esc> and :wq to write the file and quit VIM

If you exit your ssh session, and log back in, the .. command should now take you up one level in the directory hierarchy. Much nicer than having to type cd ..

Third up: bash history search command

We will be editing /etc/inputrc

The tricky part here is that /etc/inputrc is a system file, and attempting to edit it warns that I won’t be able to write and quit. I don’t have permission to edit this file. The solution is to edit it with permissions:

sudo vim /etc/inputrc

Nicely enough, the commands I want are already there; they are merely commented out:

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

All I have to do is to delete the “#” character that declares \e[5~ and \e[6~ to be a comment. With VIM, this is the x key