Introducing freebsd-update-probe (freebsd-update-probe.sh)

I've written a script that improves the efficiency of updating FreeBSD. Some backstory, last year I worked with Colin Percival, and others, to improve freebsd-update but the intertwined nature of freebsd-update with many permutations of run modes, jails/rollback and so on. Colin's lack of time meant that it was not going to fruitful so I stopped working on it. Also, Colin's focus is elsewhere (improved boot times) so it's better for everyone if he continues with that.

Recently I had an epiphany that I could implement my improvement a different way, freebsd-update-probe.sh is the result:


Written and tested on FreeBSD 13.1, 13.0, reported working on 12.2, 12.3. Not intended for use with the development versions STABLE / CURRENT (mentioned by grahamperrin below).

edit:
But I've got no updates how will I test what it will do when there are updates?
You can remove or edit /var/db/freebsd-update/tag, change/remove a single character in the file is enough. freebsd-update regenerates that file.

edit: added 13.1 to list, as mentioned below
 
Last edited:
Thanks!

Maybe add a line to clarify that it's not intended for use with STABLE or CURRENT.


Most people who are already familiar with freebsd-update(8) will know that it does not apply to STABLE or CURRENT.

People who find freebsd-update-probe in GitHub via Google or whatever might lack that knowledge.
 
Maybe add a line to clarify that it's not intended for use with STABLE or CURRENT.
I've added some info, specifying Written on FreeBSD 13.0 and noting it should be good for 12.2 ( freebsd-update still works the same way)

I would like some more information though, I've read this:
FreeBSD-STABLE is the development branch from which major releases are made
FreeBSD-CURRENT is the "bleeding edge" of FreeBSD development

I haven't used FreeBSD 14.x (development at this point in time), are they removing or changed away from freebsd-update? Or is it that development branches don't use freebsd-update anyway?
 
I think that freebsd-update was only intended for use on -RELEASE of things. I believe there is also a potential for issues when
using a non GENERIC kernel.
I can almost see this as being a wrapper or precursor to calling freebsd-update proper.
Maybe need to handle a couple of things across releases ( the -r option on freebsd-update)
but this is good stuff.
 
I can almost see this as being a wrapper or precursor to calling freebsd-update proper.
That is exactly what it is, by design. Though it is intended for a stock standard environment, for boring people like me.

I suspect a non-generic kernel would work fine.

Jails are a different animal, it was the jail stuff that ultimately stopped my fix going into freebsd-update 4 odd months ago (deep dive the bug report in the readme if you're really bored).
 
It appears to be working just fine on 12.2.

I created my own script for crontab to email me when updates are available. It's nothing fancy, but it works.

Bash:
#!/usr/local/bin/bash

# Update the probe.sh file from time to time
# https://github.com/tux2bsd/freebsd-update-probe

if [ `whoami` != 'root' ] ; then
   echo "You must be root to do this."
   exit
fi

OUTPUT="$(/home/<username>/freebsd-update-probe.sh)"

if [[ $OUTPUT == *"tag file: FAIL"* ]]; then
  echo -e "FreeBSD OS updates are available."
fi
 
Bash:
OUTPUT="$(/home/<username>/freebsd-update-probe.sh)"

if [[ $OUTPUT == *"tag file: FAIL"* ]]; then
  echo -e "FreeBSD OS updates are available."
fi
this is where exit codes come into play, rather than relying on the text output:
Bash:
/home/<username>/freebsd-update-probe.sh || echo -e "FreeBSD OS updates are available."
but I suspect you don't want the text output from freebsd-update-probe.sh, what you can do instead is (via redirection):
Bash:
/home/<username>/freebsd-update-probe.sh 1>/dev/null || echo -e "FreeBSD OS updates are available."
since that's a one-liner you can just run it and see
Bash:
if [ `whoami` != 'root' ] ; then
   echo "You must be root to do this."
   exit
fi
You can pop a 1 in there, i.e. exit 1, which means it's not successful, for what your script is mandating (if not root then no).

Mayhem30 you haven't done anything wrong, these are just hints for when you want to do more with your scripts.

Also, bash has a built-in $UID and root is UID 0 , so you can do a numeric test there instead. ( $UID is bash specific i.e. not applicable with /bin/sh ).
 
I meant to post this earlier
But I've got no updates how will I test what it will do when there are updates?
You can remove or edit /var/db/freebsd-update/tag, change/remove a single character in the file is enough. freebsd-update regenerates that file.
 
Mayhem30 you haven't done anything wrong, these are just hints for when you want to do more with your scripts.

Also, bash has a built-in $UID and root is UID 0 , so you can do a numeric test there instead. ( $UID is bash specific i.e. not applicable with /bin/sh ).

Thanks for the tips!
 
Ever so slight changes, added a "Version". Removed a sed, modifiy with awk gsub instead. Added an extra script that Mayhem30 can learn a little bash trick from.
 
I hope you got your recent updates (13.0-p11) without any issues, mine worked fine but I got annoyed with the word FAIL.

New version, 20220407, Minor change: "wording. PASS > MATCH, FAIL > CHECK. FAIL was misleading"


(Mayhem30, this is prime example of not trusting text output from a program (the exit codes are still the same, those are set in stone))
 
Last edited:
p.s. if anyone has a FreeBSD 11 install somewhere I'd be interested to know if this works on it too.
 
It worked great for me on the latest 12.3-RELEASE-p5 update.

It's difficult for me to break away from trusting text output, as that's the way I've been doing things for years now. I'm slowing breaking away from that though.
 
edit2 (top edit): freebsd-update-probe.sh works as expected on 13.1

Note freebsd-update-probe.sh this won't detect 13.1-RELEASE being available (neither does freebsd-update fetch install), upgrading releases is a separate and deliberate action. I should note that in the usage (todo done).

edit: I've updated the usage and README to reflect this, and version number bumped as the output of the usage changes.
 
Last edited:
Back
Top