Tue, 2 Apr 2024 How to get Bradley Taunt's Shinobi script to work in OpenBSD Shinobi (https://shinobi.btxx.org/feed.xml) is an interesting little blogging system. Bradley Taunt needed only 47 lines of code to create a static-site blog optimized for consumption as an RSS feed. That code in his script.sh file will run without complaint on almost all Unix/Linux systems. It should run fine in every Linux, and on NetBSD. But there's a little problem in OpenBSD and FreeBSD. I found a solution for OpenBSD, one of the systems I am running it on now. It could also work for FreeBSD but I'll have to try it when I can get some time in front of a terminal on that system. I've had problems like this before when developing scripts in Linux and then wanting to move them to a BSD system. I had one script that I wrote in Linux and then deployed to both OpenBSD and FreeBSD systems. I needed different workarounds for each of them. The utilities called by the scripts are sometimes different on the BSDs, and the script won't work until fixes are made. The date utility is the issue in the Shinobi scrpt. The problem is in line 34 of script.sh: $(date -d "$(head -n 1 $file)" +"%Y/%m/%d/%u") While all Linux/Unix systems have the date utility, not all versions of date have the same switches. There is no -d switch for date in OpenBSD and FreeBSD. NetBSD does have the -d switch for date, so that should be plug-and-play. Here are the man pages for date on all three systems: https://man.netbsd.org/date.1 https://man.freebsd.org/cgi/man.cgi?date https://man.openbsd.org/date I learned that FreeBSD used to have -d for date, but its purpose was to adjust for Daylight Saving Time, not to enter a date for parsing. The -j switch for date in OpenBSD and FreeBSD should work in the case of line 34 of the Shinobi script, but in my tests on OpenBSD, I couldn't get it right. To make the fix in OpenBSD, I needed to add the dateutils package: $ doas pkg_add -v dateutils Once that was installed, I was able to use the dateconv utility to parse the date information from the Shinobi posts and output the format needed by the script to properly order and tag the entries. I went from this: $(date -d "$(head -n 1 $file)" +"%Y/%m/%d/%u") to this: $(dateconv "$(head -n 1 $file)" -i "%a, %d %b %Y" -f "%Y/%m/%d/%u") Make that change, and script.sh should run and build feed.xml with no problems. To dig in a little bit, in dateconv, the -i switch lets the utility know what date fields you are supplying and the -f switch lets it know the format you want for the output. Feed this into your OpenBSD terminal if you want to get a feel for it: $ dateconv "Sat, 30 Mar 2024" -i "%a, %d %b %Y" -f "%Y/%m/%d/%u" 2024/03/30/6 Not bad for a few hours tinkering. Note that in OpenBSD, all the dateutils commands have "shortcuts." Instead of calling dateconv, you can use dconv -- it's the same. ---------------- You need the dateutils package to use this fix in the Shinobi script. Once you have that installed on your OpenBSD system, here is a helpful page: http://www.fresse.org/dateutils Even more helpful is the OpenBSD man page: $ man dateconv To get the overview of what comes with dateutils, go to its man page: $ man dateutils And if you're running FreeBSD and want to use the Shinobi script, dateutils is available on that platform: https://www.freshports.org/sysutils/dateutils ---------------- If you want to learn more about Shinobi, take a look at these sites: Shinobi's main Git repo: https://git.btxx.org/shinobi Bradley Taunt's Shinobi blog, which explains how to use Shinobi: https://shinobi.btxx.org/feed.xml