• Linux
  • May 2024
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Meta

Neofetch to Fastfetch

In the past few days, I’ve seen several articles and videos about the Neofetch reposistory being archived on GitHub. It hadn’t been updated in nearly four years, and the developer has reportly taken up farming. It’s still in most of the distribution repositories, but they’ll likely be dropped as the distributions update their repositories.

One of the recommended replaces I’ve been hearing about is Fastfetch, written in ‘mostly’ C with a jsonc configuration file. I took a look at the Fastfetch GitHub page and it looked pretty intersting with plently of customization options.

I downloaed and installed it. I found one of the preset configurations I liked, and added and removed a few modules from it. I also added the ASCII image that I’ve been usnig in my Neofetch configuration. I found it a bit frustrating to get it to work since I didn’t find the documentation on their GitHub and in the man page very useful. I mostly figured out by studying the presets and through trial and error.

I noticed that the information in the README file didn’t quite match up with what I was what I was experiencing, things like file names and paths for Debian installation, for instance. I also noted thet that README indicated that the current version worked with Debian 11 and newer, and Ubuntu 20.04 and newer. Looking at the Releases page, I saw that starting with version 2.8.2, the Linux binariers are built with glibc 2.35, meaning they no longer supported Debian 11 and Ubuntu 20.04. I figured that the release notes were more likely to be right and went by them. I still have a few macines running Bullseye.

Once I had it up and running on one machine, I wrote an installation script, using another of my installation scripts as a model. Getting the script right was an adventure in iteelf. Several functions and global variables from my sourced function library either didn’t work at all or behaved only. There were also some typos and varibable names that didn’t get renamed, but that’s one of the dangers of cutting and pasting code.

I tested the problem code with other scripts and on the command line, and they seemed to work fine. They just didn’t work with this script. I spent a lot of time watching the debug information as the script ran and what was being display in my terminal

In my function library I have function that takes an array of packages and checks to see if they’re installed. If they are, the function prints the package name and OK, otherwise it installs the package. The function was attempting to install each package, finding that each was was already the latest version.

One of the functions in the script that was giving me trouble was the one that downloaded the confguration and logo files from my Gitea server. To get it to work, I resorted to using hard-coded paths instead of the variables.

On a whim, I looked at the set command at the beginning of the script, set -euo pipefail. I ran the script with various combinations of options to see if one of them was causing my issues. it turns out that -o pipefail was the culprit. Without that option, the package checking function worked as it should. Then I checked the configuration download function with the variables instead of the hard-coded paths, and they worked.

I was using a script format that I use with several other applications that I install and update from their respective GitHub repositories, so I didn’t expect so many porblems. I started off with a script template and copied the applicable code from a similar script. It turns out I had not been using set -o pipefail in those script, so that would have likely caused the same problems in those script.

After struggling for two days, I now have Fastfetch with my configuration installed on all my compatible system, and it looks good. I really liked my Neofetch configuration, but this is good too.

Repo Snapshots

Back in September, I created several scripts to create daily, weekly, and monthly snapshots of my local repositories. I don’t remember for sure, but I think I was inspired by one or more videos demonstrating how to create backup using the tar command. The examples I saw were probably separate scripts for each time increment. I created my own scripts and am running them as cron jobs. That’s been working out very well.

This morning I got to thinking that I could probably combine the daily, weekly, and monthly jobs, along with the short script that syncs them to my Gitea server into one script. I cut and pasted the pertinent lines from the scripts into one script and cobbled them together into something workable. The script is meant to run as a daily cron job and use if statements to determine when each snapshot should run.

Later on, I took another look at the script and determined that I could improve upon it. I put the commands for each backup and put them in their own functions, so I could use the test brackets to call the functions, thus eliminating the if statements. The first rendition of this script used the digital representation of the days of the week to deterimine if the weekly snapshot should be performed. Rather than test for 0 or 7 representing Sunday, I changed the day of the week variable to hold the abbreviated day of week (Sun) instead, like I did with my incremental backup scripts.

This new script replaced four scripts in my crontab. It is scheduled to run daily and uses conditional statements to determine which functions will run. The current schedule of backups will be maintained with the weekly snapshot running every Sunday and the monthly on the first of the month. I believe this will be more efficient and help to declutter my crontab.

Penultimate Day 2023

I guess I was busy this year. I messed around with bash scripts a lot; writing them, modifying them, and even abandoned a few.

When I first changed my GitHub access to use SSH, I couldn’t get it working right, so I put it aside for a while, and eventually set up a local Gitea server (October 2022). This past October, I found some information that finally made GitHub usable for me again. Since my scripts repository hadn’t been touched in well over a year, I deleted all of it, and pushed some of my current scripts to it. I’m not putting all of my bash scripts on GitHub, only some that I think might be useful to others. A lot of my scripts are specific to my personal computing environment.

In the past few months, I’ve been messing around with tar as a means of archiving my financial records and my scripting projects. Now I have several incremental backups running every day. I was kind of surprised at how easy it is to work with and setting up the incremental backups was relatively painless.

Speaking of backups, I did a lot of work on my backup script based on Joe Collins’ script. I set it up mount the USB backup drive if it’s not automatically mounted. I needed that capability on my Debian i3 machines until I found a utility that would automatically mount USB drives. For a few machines where I take regular snapshots, I have it set up to recognize if the correct backup drive has been attached. I also replaced the original nested if statements with case statements for better efficiency.

Another small project of mine was to write a couple of scripts to work with downloaded ISO files. When I download an ISO from a distro’s web site, I also down its SHA checksum. My verify-iso script verifies that the checkums match. The write-iso script writes the ISO to a thumbdrive using the dd command. The scripts lists the available files and the writing script lists available removable media that can be written to.

I’ve been expanding my use of i3 on Debian. I have several laptops and a couple PCs running it on Debian 11 which I plan to upgrade to Bookworm. On the Bullseye system, I originally used Bumblebee Status as my status bar, and I’ve replaced it with Polybar. I have one laptop with an external monitor attached to play around with i3 on multiple monitors.

My son bought my wife a new computer for Christmas, and I had the pleasure of setting it up. It wasn’t nearly as painful as it used to be when I built them. Even copying her files over went rather well. Her Windows 10 computer had been acting up a lot for a while. It was slow and would often lose its network connection and the connectinons for everything else on that switch. A couple of months ago, I started setting up Linux Mint on one of my better machines, getting ready for the day her Lenovo finally died. The new machine is working well for her. It’s running Windows 11 Home which is adequate for her needs and works well in my network environment.

No Zen With Zenity

The idea of incorporating Zenity into my Bash scripts has been on my mind for some time. Having pop-up boxes to prompt for input or to enter a password, or display a warning or an error message, is intriguing. I can think of situation where having a file selector or a graphicl progress bar would be handy. I do have at least a couple of scrlpts in which such things could be very useful.

I’ve come across a lot of online articles and YouTube videos discussing and demonstrating Zenity and similar tools, but what I’ve seen tends to talk about them as individual, one-off tools, not as any kind of integrated system. I see the potential usefulness of these tools, but pop-up boxes seem kind of random, maybe even distracting. I can easily write a prompt, a warning, or an error message, even add color to make it stand out, without having to add extra code to put into a GUI box.

I’m looking to integrate them into a cohesive, integrated workflow. For instance, I have a script that takes an ISO file and its associated checksum file, compares them, shows the progress, and reports the results. The script is completely text based. It would be nice if I could bring up a tool to select the input files, show the progress of the comparison, and display the results. I also have a script to select an ISO file and a USB drive to write it to using the dd command. I’d like to have a simple graphical tool to select the file and the device, write the file to the device, ideally while showing the progress of the operation, and showing success or failure. I’m sure it wouldn’t be very difficult.

Messing with backups

Lately, I’ve been exploring the tar command and tinkering with backups. I don’t know why I’ve never looked into it before. I’ve been using rsync to create snapshots of my home directory on my “production” machines. While technically, not a back up, these snapshots have been useful. I’ve also use rsync to copy certain directories to computers across my network. Over the years, I’ve also written scripts that use zip to create compressed archives of my script directory along with some other directories.

About a month ago I created a few scripts to make, daily, weekly, and monthly snapshots of my local repositories using tar. That’s been working well, and it prompted me to look into setting up incremental and differential backups using tar. I found some articles and YouTube videos on the subject to get familiar with the concepts. It wasn’t until I started actually experimenting with it, that it began to gel, and I cobbled together a couple of rudimentary backup scripts. Soon I was able to flesh them out and write scripts for incremental and differential backups.

I created scripts to make incremental backups of my two main repository directories. One contains a local copy of my public repositories that I have on Github, and the other is my private repository that I store on a local server. As of this writing I’ve only done the initial full backup of the repositories, so it will take awhile to see how well it works. I’ll probably still have to deal with a few bugs. Within hours of doing the first backups, I found a couple of minor bugs which I fixed straight away. They didn’t affect anything operation, they were just minor cosmetic issues how the archive files were named.

I have the scripts setup to append the archive name with a six-digit date (yymmdd) followed by the numerical day of week (0-6). A full backup is done on Sunday (day 0) and incrementals are done the next six days. On Sunday the metadata file is renamed using the date for the previous Sunday and a new metadata file is created for the next week. It will be at least a couple of weeks before I know it’s working as expected, but I’m confident I’ve got it right.

If this works out I’m thinking about implementing incremental backups for other important directories and backing up to external drives. Delving into using tar with incremental and differential backups has kind of opened up some new possibilities.

Update on my GitHub Repos

After GitHub changed to using SSH to push commits to repositories a couple of years ago, I tried to get that all set up and, for the life of me, I couldn’t get it to work. I was apparently missing something, so I gave up on it. About a year ago, I set up a local Gitea server on my home network and that’s been working well for me. The biggest disadvantage of that was there was no access to from outside my network. Everything on my Gitea server is primarily for my own use, but I do have some scripts and projects I might want to share. In the meantime, everything I had on GitHub was sitting stagnant and well out of date.

A few days ago, I decided to take another look at my GitHub presense. I successfully set up my SSH public key on GitHub, and after searching online, I found a couple of git commands that got my old repositories talking to GitHub again via SSH. Then I set forth to update the repositories. I archived the homebankarchive and yt-dl-utilities repos since they’re probably not very useful. I’ll probably remove them complete soon. The FnLoC and FnLoC-Win repositories are still current despite not having done any work on them in a few years. There are some features and improvements I’d like to make, but I don’t know how to implement them. My knowledge of C programming has diminished over the years.

Then I began updating the bashscripts repository by importing up-to-date versions of the scripts from my Gitea repo and pushing them up to GitHub. I also removed some scripts that were of dubious interest. In the last few days I’ve been going through my scripts n the Gitea server, and exporting some of them that others might find useful. I’ve been adding new scripts to the repo a couple at a time and updating them as needed.

For those who are interested, here’s my GitHub.

My Scripts for ISOs

I’ve never really been into distro-hopping, but I do occasionally put different distros in VMs or actual hardware. I currently run Debian, Linux Mint, Linux Mint Debian Edition, MX Linux, and BunsenLabs on different machines. I keep current ISO files for these distributions as well as a few others that look interest me.

I haven’t always checked the ISO files I download against the checksum files. It seemed like a hassle to do it, but I always confirm that the files I download are genuine.

When I need to install a distro on a laptop or desktop, I generally need write the ISO to a USB stick. Some distros, like Mint, have a utility for that, but I’ve found that it’s not always reliable. I’ve copied ISO files to a USB drive with Ventoy installed, but my experience with Ventoy has been rather disappointing. Sometimes it works, and sometimes it doesn’t.

The most consistent method I’ve found, particularly for Debian and Debian-based distributions, has been using dd to write the ISO to a USB drive. As everyone knows, dd is potentially dangerous.

To deal with these problems, I’ve written a couple of scripts to verify and reduce the risks. They aren’t fullproof, but they’ve worked well for me.

My check-iso script displays the ISO and checksum files in a directory and prompts me to enter the appropriate files. I can either type them in, but I usually highlight the file with my mouse and use the center-click to copy it to the prompt. I don’t know if that works in all terminals, but it works in Kitty and Terminator. The script then compares the two checksums and tells me whether they match.

When I download an ISO file from a distro’s website, I get the checksum and put it in a file whose name identifies the distro and the type of checksum, for example, distro-iso.sha256. If the site’s checksum file contains checksums for multiple versions, I’ll break that file down into individual files for each because my script reads the first field on the first line.

The write-iso script lists the available ISO files and a prompt. Then it checks to see if a USB drive is attached and mounted, and lists the available removal media with its capacity. The user enters the appropriate device at the prompt and is prompted to confirm the choice which must be explicity answered with yes or no.

When it comes to scripts, like a poem, they’re never finished. Most of the time, they’re abandoned when they’ve outlived their usefulness or I find something else that does the job better.

BU Revisited

I’ve recently made a couple of significant changes to Joe Collins’ BU script. With as many modifications I’ve made, it hardly resembles Joe’s original script. The backup, restore, and help functions are still mostly as he wrote them although I have made some changes to them.

One change I made since my April post, Joe’s Backup Script, was to change the if-elif-else construct of checking the command line arguments to a case statement. The default action with no arguments is still to run a backup, but now I’ve allowed explicitly entering it as an option.

Most recently, I discovered a video and an accompanying script by Kris Occhipini that demonstrated a method of checking for a removable drive’s UUID and mounting it. It inspired me to create a function that I could incorporate into the BU script to determine if a paticular backup drive was connected to the appropriate computer, thus preventing me from inadverantly backing up a system to the wrong drive and potentially running out of space.

The function has the backup drive UUID’s and the computer hostnames held in variables and checks for the appropriate UUID. If it detects one of them, it compares the hostname with the hostname associate with that drive. If I have the wrong drive/hostname combinatiion, the function returns a failure code and the script exits with an appropriate error message. Should one of these drives be connected to one of my test computers, it raises the error condition, preventing an extraneous backup on that drive. Should an unlisted backup drive be attached, the backup script will still continue normally. This allows me to use the script to backup my home directory on my test machines.

I initially assigned the UUIDs and the target hostnames to individual variables, and later decided that using arrays to hold this information would be a better way to go. That worked well, and the function looks nicer. It will probably be easier to maintain as long as I keep each UUID associated with the proper hostname.

A special thanks to Joe Collins and Kris Occhipini for sharing their work. They’ve inspired me and provided me with the tools to build upon.

LMDE Woes

My HP EliteDesk 800 G1 Desktop Mini has had some issues for quite a while. Several months ago, shortly before the release of LMDE 4, I was having problems connected to it via SSH and when LMDE 4 came out I upgraded it from LMDE 3.

Recently, the system seemed rather slow but I couldn’t get a handle on what was causing it. Then, earlier this month, after I rearranged things, I found that it had no video when connected to my KVM. I finally hooked it up to its own keyboard, mouse and monitor. I did find the cause of the slowness. There was a brtty daemon running in the background. How it got there, I haven’t a clue, but once I removed it, it seemed to run pretty well.

Yesterday when I was synchronizing file from my computer with it, I started getting errors about the home partition being read-only. I did some research on the problem and tried several proposed solution but none worked. I looked at the drive with the Gnome Disks utility and saw that it had eight bad sectors. I tried to check and repair it but I got a messaging saying the partition was “busy.” It was then I decided to grab another hard drive and load Debian Buster on it.

It was during the process of configuring the machine after the Buster installation, that I started having some problems with my network, but once I straightened that out, things went fairly well.

This was a good test of some of my installation scripts and tweaking was done. A couple of software installation scripts also had to be tweaked and one script was almost completely rewritten.

Hopefully, this machine will run without problems for more than a few months. It’s possible that the old hard drive may have been the root of the problems. Normally, I don’t worry too much about a few bad sectors but I keep an eye on it. I’ve seen bad sectors grow like a cancer. And if the bad sectors are in critical areas, they can adversely affect the whole system.

Getting Ready to Rip

The other day I decide that I would finally set up a computer to “rip” music from CDs, tapes, and LPs to digital format. This has been on my to-do list for quite a while.

HP-800-G1-USDTI installed Linux Mint 19.1 Tessa on a refurbished HP Elitebook 800 G1 USDT into which I’d installed 16GB of RAM and a 750 GB hard drive. The installation when very well although I had to do a little tweaking of some of my software installation scripts. They’re working right now.

I installed Asunder CD Ripper, Audacity, Brasero, EasyTAG, Normalize-audio and HandBrake. EasyMP3Gain and mp3gain are no longer available in the Mint/Ubuntu repositories so I hope Normalzize-audio will do the job. I installed HandBrake so I can rip my DVDs (for backup purposes, of course). I’ll probably add additional software as I get going. It’s been a while since I’ve ripped cassette tapes (on an old Windows machine).

As I remember, ripping tapes was a laborious process. It took 45 minutes to record one side of a 90-minute tape to a WAV file, then I had to bring it up in an audio editor to break it into individual tracks before finally converting them to mp3 files. I doubt that the process has sped up much, if at all.