Commit Diff


commit - /dev/null
commit + df63222493325e8d62200f5f1770bf942f03f666
blob - /dev/null
blob + d5ae84872a810039635600eb53a60b80d84308df (mode 644)
--- /dev/null
+++ LICENSE
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2024 Chaz Kettleson <chaz@pyr3x.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
blob - /dev/null
blob + 142813e7b3d863b214fd62c066f795ca3e1698fe (mode 644)
--- /dev/null
+++ README
@@ -0,0 +1,44 @@
+Similar to syspatch(8) with the -c switch, this script supports checking
+for updates to packages suitable for cron(8).
+
+This script will run 'pkg_add -Uun' to determine which packages would
+have been updated and stores the result. It then removes packages
+starting with 'quirks' (a required package on OpenBSD) and determines
+how many remain. If there are no packages, return 0, otherwise, echo the
+package names and return 2. Returning 0 or 2 is significant because
+crontab(5) with the -n switch determines whether to send mail. Since we
+are likely to run this nightly, we do not want to flood our inbox with
+output from cron when there is no action to take. By exiting with a
+non-zero (2) exit status when there are packages, we can ensure we only
+get email if there are package updates.
+
+Save the above script to '/usr/local/bin/pkg_update' and run the
+following commands for the proper user/group ownership and permissions.
+
+$ doas chmod 755 /usr/local/bin/pkg_update
+$ doas chown root:bin /usr/local/bin/pkg_update
+
+We now need to add it to root's crontab.
+
+$ doas crontab -e
+
+At the bottom add the following line:
+
+0 0 * * * -ns /usr/local/bin/pkg_update
+
+Notice the -n switch to not mail on a successful run. We have
+purposefully setup the script to have a non-successful (non-zero) exit
+when there are no packages to update thus generating the email.
+
+You may also opt to add this script to /etc/daily.local with the single
+line:
+
+/usr/local/bin/pkg_update
+
+However, it should be noted that this script is designed with return
+values for direct use in crontab(5). If being called from the /etc/daily
+script, you'll likely want to add some additional messages to be echoed
+either in the script directly or in /etc/daily.local.
+
+It is highly recommended to setup a user account where root's email can
+be forwarded. See afterboot(8) section 'Mail aliases'.
blob - /dev/null
blob + c1ddac2a4cdf5defe3163afb3c2a7c610434a140 (mode 755)
--- /dev/null
+++ pkg_update
@@ -0,0 +1,10 @@
+#!/bin/ksh
+PACKAGES=`/usr/sbin/pkg_add -Uun`
+NOQUIRKS=`/bin/echo $PACKAGES | grep -e '^quirks' -v | /usr/bin/wc -l`
+if [ "$NOQUIRKS" -eq "0" ]; then
+	/bin/echo "No package updates available"
+	return 0
+else
+	/bin/echo $PACKAGES
+	return 2
+fi