r/openbsd • u/gentisle • 1d ago
Exit Code syspatch
I’m looking to find a way to know if syspatch -c can tell a script that A. there are patches and then execute a syspatch to apply, or B. there are no patches and simply exit. man page says exit code is zero for success and greater for anything else. Trying this, I find that syspatch -c returns zero when there are patches to be applied. I want the script to discern that there are patches and then issue the command to apply. Am I going about this the wrong way?
12
Upvotes
4
u/jggimi 1d ago
Your intended automation may not provide what you are expecting. Applying a patch makes changes to your filesystem, but does not ensure it that change is deployed. Affected daemons will need to be restarted. If a kernel patch is applied, the OS will require rebooting.
5
u/xzk7 1d ago
This is the script I run on all my hosts, it sends a ntfy.sh request to let me know if there are any updates I need to apply, then I apply them when I have a chance to do it (rebooting requires me to enter disk passphrase manually by design.)
After any patches or firmware updates I have it remind me to reboot the system. Thought I'd share. You can probably adapt to whatever you're trying to do. Good luck
4
u/Educational_Bee_6245 1d ago
I guess you have to parse the output. If there are no patches there is no output, so easy.
1
u/faxattack 1d ago
I have something like this crontabbed on production systems, works as expected:
syspatch && reboot