Skip to content

Instantly share code, notes, and snippets.

@vilhelmen
Last active August 15, 2021 09:55
Show Gist options
  • Save vilhelmen/95fddc211408d75679563736358baba0 to your computer and use it in GitHub Desktop.
Save vilhelmen/95fddc211408d75679563736358baba0 to your computer and use it in GitHub Desktop.
Pfsense unifi installer stuff
#!/bin/sh
ABI=`/usr/sbin/pkg config abi`
# Modify /usr/local/etc/pkg/repos/pfSense.conf to include FreeBSD data:
# FreeBSD: {
# url: "pkg+https://pkg.freebsd.org/${ABI}/latest",
# mirror_type: "srv",
# signature_type: "fingerprints",
# fingerprints: "/usr/share/keys/pkg/",
# enabled: no
# }
# For best safety, extract current config, delete, add, work, restore?
# Ugh just copy it over to /tmp and assume the default config
cp /usr/local/etc/pkg/repos/pfSense.conf /tmp/pfSense.conf
fgrep -v 'FreeBSD: { enabled: no }' /tmp/pfSense.conf > /usr/local/etc/pkg/repos/pfSense.conf
cat << EOF >> /usr/local/etc/pkg/repos/pfSense.conf
FreeBSD: {
url: "pkg+https://pkg.freebsd.org/${ABI}/latest",
mirror_type: "srv",
signature_type: "fingerprints",
fingerprints: "/usr/share/keys/pkg/",
enabled: yes
}
EOF
# pkg wants to update, please don't
pkg lock pkg
# maybe just yes | pkg lock -a
pkg install unifi6
# RESTORE PACKAGE LOCK
# yes | pkg unlock -a
# Unecessary icu lock if unifi locked?
# boost/mongo lock does NOT lock icu, so yes.
pkg unlock pkg
# This does not seem needed at or around 2.4.5-p1
pkg lock icu
# Restore package conf
cp /tmp/pfSense.conf /usr/local/etc/pkg/repos/pfSense.conf
# fix java launch
# look into integrating boot speedup fix in the custom launcher
sed -i.bak -e 's|com.ubnt.ace.Launcher|-jar /usr/local/share/java/unifi/lib/ace.jar|g' /usr/local/etc/rc.d/unifi
rm /usr/local/etc/rc.d/unifi.bak
mv /usr/local/etc/rc.d/unifi /usr/local/etc/rc.d/unifi.sh
if [ ! -f /etc/rc.conf.local ] || [ $(grep -c unifi_enable /etc/rc.conf.local) -eq 0 ]; then
echo -n "Enabling the unifi service..."
echo "unifi_enable=YES" >> /etc/rc.conf.local
echo " done."
fi
service unifi.sh start
@vilhelmen
Copy link
Author

vilhelmen commented Jul 22, 2020

Need to track installed packages/version delta for rollback/uninstall.

pkg query -a '%n %R' | fgrep -v 'pfSense' is nice but not perfect

Upgrading pfsense while the unifi stuff is installed does not end well.

Right now the best move is to just reinstall and restore. But I'm worried a reinstall will nuke my zfs disk. It's not perfect :/

@vilhelmen
Copy link
Author

Upgrade from 5 to 6 went smooth. Stop service, enable BSD repo, upgrade unifi5 (got freshest versions of mongo, etc. Installed a new tif lib?), remove unifi5, install unifi6 (going straight to 6 would not uninstall 5, and installing 6 did not seem to want to update dependencies like the 5 upgrade did), disable repo, resync the service file, and reboot.

@vilhelmen
Copy link
Author

vilhelmen commented Aug 15, 2021

Repo enabling should be changed to toggling the enabled status in /usr/local/etc/pkg/repos/pfSense.conf. Attempting to upgrade pfsense without a fresh install and restore.

LMAO, pfsense updater marks it and its dependencies to be uninstalled, cool. Thanks for that.

Installed packages to be REMOVED:
	mongodb36: 3.6.21
	openjdk8: 8.275.01.1
	py37-maxminddb: 1.4.1_1
	py37-ply: 3.11
	py37-setuptools: 41.4.0_1
	py37-sqlite3: 3.7.7_7
	python37: 3.7.7
	snappyjava: 1.1.7.5
	unbound: 1.10.1
	unifi6: 6.2.26

No longer boots. Why is this always so difficult. Starting fresh.

Still doesn't work. Netgate didn't test 2.5.x on the hardware they sold me. At least it's not my fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment