From e226092abe5ae4956c19c702fe3e7f6fc36ddc08 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 7 Feb 2025 08:46:51 +0100 Subject: [PATCH] firmware: add an upgrade test for wrong pkg repository PR: https://forum.opnsense.org/index.php?topic=45614.0 --- src/etc/rc.syshook.d/upgrade/10-sanity.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/etc/rc.syshook.d/upgrade/10-sanity.sh b/src/etc/rc.syshook.d/upgrade/10-sanity.sh index 779cc153a..19d4b7874 100755 --- a/src/etc/rc.syshook.d/upgrade/10-sanity.sh +++ b/src/etc/rc.syshook.d/upgrade/10-sanity.sh @@ -1,17 +1,28 @@ #!/bin/sh CORE=$(opnsense-version -n) +PKG="/usr/local/sbin/pkg-static" if [ -z "${CORE}" ]; then echo "Could not determine core package name." exit 1 fi -if [ -z "$(/usr/local/sbin/pkg-static query %n ${CORE})" ]; then +if [ ! -f "${PKG}" ]; then + echo "No package manager is installed to perform upgrades." + exit 1 +fi + +if [ -z "$(${PKG} query %n ${CORE})" ]; then echo "Core package \"${CORE}\" not known to package database." exit 1 fi +if [ "$(${PKG} query %R pkg)" = "FreeBSD" ]; then + echo "The Package manager \"pkg\" is incompatible and needs a reinstall." + exit 1 +fi + echo "Passed all upgrade tests." exit 0