From 3dcf6016f8c318ea4c4115aabe6395a43fd8e807 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Mon, 7 Aug 2023 20:10:23 -0700 Subject: [PATCH] fix the mongodb install issues on 2.7.0 See also: https://github.com/unofficial-unifi/unifi-pfsense/issues/320#issuecomment-1646732257, but TL;DR: - pfSense 2.7.0 forked off from FreeBSD 14.0-pre at some time N - FreeBSD 14.0-pre switched to OpenSSL 3.0 in base at some time N+1 - we pull from `FreeBSD:14:x` "latest" here - thus "latest" expects OpenSSL 3.0, but we (pfSense) have a base with OpenSSL 1.x Thus, mongodb from FreeBSD:14:x errors out with missing `libssl.so.30` linking errors. https://github.com/pfsense/FreeBSD-src/commit/b077aed33b7b6aefca7b17ddb250cf521f938613 says that we're gonna get OpenSSL 3.0 *eventually* in pfSense, but for now, we can pull from FreeBSD:13:x if we see that bad combination of `(abi, pfSense version)`. --- install-unifi/install-unifi.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install-unifi/install-unifi.sh b/install-unifi/install-unifi.sh index 4ba0ce6..f03a110 100644 --- a/install-unifi/install-unifi.sh +++ b/install-unifi/install-unifi.sh @@ -11,6 +11,12 @@ UNIFI_SOFTWARE_URL="https://dl.ui.com/unifi/7.2.97/UniFi.unix.zip" RC_SCRIPT_URL="https://raw.githubusercontent.com/unofficial-unifi/unifi-pfsense/master/rc.d/unifi.sh" CURRENT_MONGODB_VERSION=mongodb42 +MONGO_NEEDS_FALLBACK_VERSION="2.7." +MONGO_NEEDS_SSL="/usr/lib/libssl.so.30" +if [ $(pkg config abi | grep -c "FreeBSD:14:") -eq 1 ] && [ $(grep -c $MONGO_NEEDS_FALLBACK_VERSION /etc/version) -eq 1 ] && [ ! -f $MONGO_NEEDS_SSL ]; then + FALLBACK_MONGO_ABI="FreeBSD:13:$(pkg config abi | awk -F ':' '{print $3}')" + FALLBACK_MONGO_PACKAGE_URL="https://pkg.freebsd.org/${FALLBACK_MONGO_ABI}/latest/" +fi # If pkg-ng is not yet installed, bootstrap it: if ! /usr/sbin/pkg -N 2> /dev/null; then @@ -107,10 +113,11 @@ tar vfx packagesite.pkg AddPkg () { pkgname=$1 + base_url=${2:-FREEBSD_PACKAGE_URL} pkg unlock -yq $pkgname pkginfo=`grep "\"name\":\"$pkgname\"" packagesite.yaml` pkgvers=`echo $pkginfo | pcregrep -o1 '"version":"(.*?)"' | head -1` - pkgurl="${FREEBSD_PACKAGE_URL}`echo $pkginfo | pcregrep -o1 '"path":"(.*?)"' | head -1`" + pkgurl="${base_url}`echo $pkginfo | pcregrep -o1 '"path":"(.*?)"' | head -1`" # compare version for update/install if [ `pkg info | grep -c $pkgname-$pkgvers` -eq 1 ]; then @@ -161,7 +168,11 @@ AddPkg snappy AddPkg cyrus-sasl AddPkg icu AddPkg boost-libs -AddPkg ${CURRENT_MONGODB_VERSION} +if [ -n "$FALLBACK_MONGO_PACKAGE_URL" ]; then + AddPkg ${CURRENT_MONGODB_VERSION} ${FALLBACK_MONGO_PACKAGE_URL} +else + AddPkg ${CURRENT_MONGODB_VERSION} +fi AddPkg unzip AddPkg pcre