On Sun, Dec 06, 2020 at 02:19:05PM +0000, SW wrote: > Hi, > I've been looking to have syspatch give me a quick indication of whether > a reboot is likely to be required. As a quick and dirty check, I've just > been treating "Were patches applied?" as the indicator. > > The following diff will cause syspatch to exit when applying patches > with status code 0 only if patches were actually applied. > > My biggest concern is that it does cause a change in behaviour, so > perhaps this either needs making into an option or a different approach > entirely? > > --- syspatch Sun Dec 6 14:11:12 2020 > +++ syspatch Sun Dec 6 14:10:23 2020 > @@ -323,3 +323,9 @@ if ((OPTIND == 1)); then > _PATCH_APPLIED=true > done > fi > + > +if [ "$_PATCH_APPLIED" = "true" ]; then > + exit 0 > +else > + exit 1 > +fi > > Thanks, > S
$_PATCH_APPLIED will be "true" or "false", which means that you could use it as is done elsewhere in the script: $_PATCH_APPLIED If that is the last line of the script, it (true or false) will supply the exit status of the script. No need for an if statement or explicit exit. Returning a non-zero exit status is generally a sign of some sort of failure. Not applying a patch due to already having the patch applied is not really a failure. Instead, you could run syspatch -c from a regular cron job and patch+reboot whenever that tells you there's new patches available. -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .