💾 Archived View for eridanus.us › updaters.gmi captured on 2024-06-16 at 12:03:03. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-01-08)
-=-=-=-=-=-=-
When I use software that is not managed by the built-in package manager on my Linux machine, I like to write shell scripts that handle updates for me. These scripts go in a folder called "updaters" in my folder for personal binaries (in my case ~/.bin). I then run a function from my bashrc called "ud" which executes all of the *.ud files in the "updaters" directory within my personal binaries directory.
If you want to do something similar on your Linux machine, you will need a function like this in your bashrc to get the ball rolling:
ud () { updaters="$HOME/.bin/updaters/*.ud" for exe in $updaters; do if [[ ! -x "$exe" ]]; then chmod +x "$exe" if [[ ! $? ]]; then echo "$exe" cannot be made executable continue fi fi eval "$exe" || echo "$exe" could not be executed done }
Next, you need an updater to put in said directory. Below is one I've written to keep Amfora up to date (scroll down for the file download). Note that you need curl, wget, sed, and awk for this to work. I acknowledge that I could have picked only curl or wget and pair it with only sed or awk, but I just hacked these together one step at a time and used the tool that felt the most natural at the time. Regardless, it works, so I am reluctant to change it much
#!/bin/bash # root for relative links root=github.com # location of Amfora releases releases=https://github.com/makeworld-the-better-one/amfora/releases # architecture of the executable arch=linux_64 # possible values for $arch are: freebsd_64-bit openbsd_64-bit netbsd_32-bit # netbsd_64-bit freebsd_32-bit windows_64-bit.exe macOS_arm64 linux_32-bit # linux_64-bit openbsd_32-bit linux_arm64 windows_32-bit.exe linux_armv7 # linux_armv6 macOS_64-bit # (note that you can truncate these as long as the truncation is unique) # find the relative link of the latest executable link=$(curl -s $releases | grep "/releases/download/" | grep -m 1 "$arch" | sed 's/"//g' | awk '{print $2}') # trim the href tag from the beginning link=${link:6} # determine the name of the executable (used for version control too) exe=$(cut -d/ -f6 <<<"${link}") # make sure to do things in the right directories cd "$(dirname "$0")" || exit $? # name of the executable to go in your binaries directory name=amfora # logic to ensure the executable is only updated when necessary and to link it # to the directory above the current one if [ ! -f "$exe" ]; then rm -f ${name}_???* wget -q $root/"$link" chmod +x "$exe" ln -f "$exe" "../$name" echo Amfora updated else echo Amfora is up to date fi
And here are some others I've written:
gemget.ud (gemget is basically wget for Gemini)
agate.ud (Agate is a lightweight Gemini server for static content)
styli.sh.ud (styli.sh is a nice wallpaper picker/setter written in Bash)
The scripts shown and linked to on this page (including the "ud" function) are given freely without license, warranty, or guarantee of functionality. You are free to use and modify them without risk of copyright infringement.
--------------------