Re: [PATCH]: Add a check for upgrade feature to sysupgrade(8)
On Mon, 3 Aug 2020 13:28:38 +0200 Emil Engler : > ## Abstract > This patch adds an argument to sysupgrade(8) which makes it possible > to check if an upgrade is available, similar to "syspatch -c". > This works both, for snapshots and releases. > > ## Usage > Add "-c" to sysupgrade. > If the script exits with a zero, an upgrade is available. If it fails > you are already on the newest version or an upgrade cannot be pulled > for whatever reason. > > ## Motivation > I want a cronjob on my desktop (which is on -current) that checks > regularly if a new snapshot is available and notifies me if this is > the case. syspatch(8) already has such a feature, so why not add > one to sysupgrade? Also it could be useful on -stable and -release > systems. it seems to me you could use this in your crontab sysupgrade -n | grep "Already on last snapshot" || sh send_mail_new_snasphot.sh
Re: [PATCH]: Add a check for upgrade feature to sysupgrade(8)
Indeed, it will still download and install it. It is unsuitable because after the mail was sent it can already be too late and it can take lots of network bandwidth. This can be problematic for various reasons. On 2020-08-03 15:10, Stuart Henderson wrote: > On 2020/08/03 13:50, Solene Rapenne wrote: >> On Mon, 3 Aug 2020 13:28:38 +0200 >> Emil Engler : >> >>> ## Abstract >>> This patch adds an argument to sysupgrade(8) which makes it possible >>> to check if an upgrade is available, similar to "syspatch -c". >>> This works both, for snapshots and releases. >>> >>> ## Usage >>> Add "-c" to sysupgrade. >>> If the script exits with a zero, an upgrade is available. If it fails >>> you are already on the newest version or an upgrade cannot be pulled >>> for whatever reason. >>> >>> ## Motivation >>> I want a cronjob on my desktop (which is on -current) that checks >>> regularly if a new snapshot is available and notifies me if this is >>> the case. syspatch(8) already has such a feature, so why not add >>> one to sysupgrade? Also it could be useful on -stable and -release >>> systems. >> >> it seems to me you could use this in your crontab >> >> sysupgrade -n | grep "Already on last snapshot" || sh >> send_mail_new_snasphot.sh >> > > That won't just check, it will stage the release for install on next boot. >
Re: [PATCH]: Add a check for upgrade feature to sysupgrade(8)
On 2020/08/03 13:50, Solene Rapenne wrote: > On Mon, 3 Aug 2020 13:28:38 +0200 > Emil Engler : > > > ## Abstract > > This patch adds an argument to sysupgrade(8) which makes it possible > > to check if an upgrade is available, similar to "syspatch -c". > > This works both, for snapshots and releases. > > > > ## Usage > > Add "-c" to sysupgrade. > > If the script exits with a zero, an upgrade is available. If it fails > > you are already on the newest version or an upgrade cannot be pulled > > for whatever reason. > > > > ## Motivation > > I want a cronjob on my desktop (which is on -current) that checks > > regularly if a new snapshot is available and notifies me if this is > > the case. syspatch(8) already has such a feature, so why not add > > one to sysupgrade? Also it could be useful on -stable and -release > > systems. > > it seems to me you could use this in your crontab > > sysupgrade -n | grep "Already on last snapshot" || sh > send_mail_new_snasphot.sh > That won't just check, it will stage the release for install on next boot.
[PATCH]: Add a check for upgrade feature to sysupgrade(8)
## Abstract This patch adds an argument to sysupgrade(8) which makes it possible to check if an upgrade is available, similar to "syspatch -c". This works both, for snapshots and releases. ## Usage Add "-c" to sysupgrade. If the script exits with a zero, an upgrade is available. If it fails you are already on the newest version or an upgrade cannot be pulled for whatever reason. ## Motivation I want a cronjob on my desktop (which is on -current) that checks regularly if a new snapshot is available and notifies me if this is the case. syspatch(8) already has such a feature, so why not add one to sysupgrade? Also it could be useful on -stable and -release systems. ## Notes This was already brought up a year ago by Andrew Klaus, however it got no feedback at all. Also this diff is a smaller one. The Message-ID of that patch: c714aaea-208a-346f-9d83-20e590888fb1 Feedback and thoughts? Index: usr.sbin/sysupgrade/sysupgrade.8 === RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v retrieving revision 1.10 diff -u -p -u -p -r1.10 sysupgrade.8 --- usr.sbin/sysupgrade/sysupgrade.83 Oct 2019 12:43:58 - 1.10 +++ usr.sbin/sysupgrade/sysupgrade.83 Aug 2020 10:44:53 - @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 3 2019 $ +.Dd $Mdocdate: August 3 2020 $ .Dt SYSUPGRADE 8 .Os .Sh NAME @@ -22,7 +22,7 @@ .Nd upgrade system to the next release or a new snapshot .Sh SYNOPSIS .Nm -.Op Fl fkn +.Op Fl fknc .Op Fl r | s .Op Ar installurl .Sh DESCRIPTION @@ -60,6 +60,9 @@ By default they will be deleted after th Fetch and verify the files and create .Pa /bsd.upgrade but do not reboot. +.It Fl c +Check if there is an upgrade available. It will succeed if a new version +is available or will fail if not. .It Fl r Upgrade to the next release. This is the default if the system is currently running a release. Index: usr.sbin/sysupgrade/sysupgrade.sh === RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v retrieving revision 1.39 diff -u -p -u -p -r1.39 sysupgrade.sh --- usr.sbin/sysupgrade/sysupgrade.sh 4 Jul 2020 18:30:46 - 1.39 +++ usr.sbin/sysupgrade/sysupgrade.sh 3 Aug 2020 10:44:53 - @@ -34,7 +34,7 @@ ug_err() usage() { - ug_err "usage: ${0##*/} [-fkn] [-r | -s] [installurl]" + ug_err "usage: ${0##*/} [-fknc] [-r | -s] [installurl]" } unpriv() @@ -75,12 +75,14 @@ SNAP=false FORCE=false KEEP=false REBOOT=true +CHECK=false -while getopts fknrs arg; do +while getopts fkncrs arg; do case ${arg} in f) FORCE=true;; k) KEEP=true;; n) REBOOT=false;; + c) CHECK=true;; r) RELEASE=true;; s) SNAP=true;; *) usage;; @@ -146,6 +148,14 @@ rm SHA256.sig if cmp -s /var/db/installed.SHA256 SHA256 && ! $FORCE; then echo "Already on latest snapshot." + if $CHECK; then + exit 1 + fi + exit 0 +fi + +if $CHECK; then + echo "Upgrade is available" exit 0 fi