This adds the ability to check if you're running the latest release, without actually upgrading. I'd like to use this functionality when writing an Ansible module for sysupgrade soon. I already have one for syspatch that's been accepted today.

This follows the same usage (-l) as syspatch(8) to list if an update is available.

Andrew

Index: sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.21
diff -u -p -u -r1.21 sysupgrade.sh
--- sysupgrade.sh       14 May 2019 14:27:49 -0000      1.21
+++ sysupgrade.sh       1 Jun 2019 07:28:10 -0000
@@ -33,7 +33,7 @@ ug_err()

 usage()
 {
-       ug_err "usage: ${0##*/} [-fkn] [-r | -s] [installurl]"
+       ug_err "usage: ${0##*/} [-fkln] [-r | -s] [installurl]"
 }

 unpriv()
@@ -73,12 +73,14 @@ RELEASE=false
 SNAP=false
 FORCE=false
 KEEP=false
+LIST=false
 REBOOT=true

-while getopts fknrs arg; do
+while getopts fklnrs arg; do
        case ${arg} in
        f)      FORCE=true;;
        k)      KEEP=true;;
+       l)      LIST=true;;
        n)      REBOOT=false;;
        r)      RELEASE=true;;
        s)      SNAP=true;;
@@ -116,6 +118,16 @@ if $SNAP; then
        URL=${MIRROR}/snapshots/${ARCH}/
 else
        URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/
+fi
+
+if ${LIST} && ${RELEASE}; then
+       set +e
+ if unpriv -f SHA256.sig ftp -Vmo /dev/null ${URL}SHA256.sig 2>/dev/null; then
+               echo "Release available: ${NEXT_VERSION}."
+       else
+               echo "Already on latest release."
+       fi
+       exit
 fi

 if [[ -e ${SETSDIR} ]]; then

Reply via email to