Scroll Top
Evotec Services sp. z o.o., ul. Drozdów 6, Mikołów, 43-190, Poland

Using PowerShell to fix Ubiquiti Unifi requirement for MongoDB 3.6 on Ubuntu 18

Unifi PowerShell

I've been using Ubiquiti Unifi for some years now, for both home and work usage. It's great hardware at a great price, and the best thing for a software maniac like me is that it's continuously updated. Some time ago I upgraded Ubuntu to 18.04, and things went a bit sideways. You see Unifi started to add to their DEB packages that Mongo 3.6 is not supported and therefore blocking any installation. The idea is, it works perfectly fine on MongoDB 3.6 but migration between 3.4 to 3.6 is just not straightforward. Long story short when I upgraded Ubuntu I was suddenly greeted with not working Unifi.  I've fixed that, and blogged about it how you can do so using manual steps – Ubuntu 18.04 – Fixing Unifi .deb package to run with 3.6 MongoDB. The thing is with each new version out I have to do multiple steps to fix every single package from Unifi (you see where I'm going right?). While a few years ago I would be stuck to use bash or some other workaround which would be a pain for me, this is 2019, and PowerShell Core works excellent on Linux systems! I know that installing PowerShell Core for hardcore Linux fans may not be as fun as it is for me, but you do get a lot of benefits from it.

Installing PowerShell Core on Ubuntu

If you don't have PowerShell available on your Ubuntu machine you can easily install this using Microsoft recommended steps. Those are below. If you have a different version of the system and you want to give PowerShell Core a try you can find instructions on Installing PowerShell Core on Linux on Microsoft website.

# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of products
sudo apt-get update

# Install PowerShell
sudo apt-get install -y powershell
Starting PowerShell Core on Ubuntu and Installing PSUnifi

If you already have PowerShell installed, you can simply start PowerShell Core

# Start PowerShell
pwsh

As with most of my scripts, this one is available as PowerShell module and can be installed from PowerShellGallery.

Install-Module PSUnifi

# For updates in case there will be updates to my module
# Update-Module PSUnifi

Full sources are available on GitHub.

Using Repair-UnifiPackage to remove MongoDB dependencies from package

Usage is straightforward. Just type command and give the URL parameter to a deb package. It will download the package to a temporary directory, unpack it, fix dependencies, pack it and save in temporary location for installation purposes.

Repair-UnifiPackage -Url 'https://dl.ubnt.com/unifi/5.10.20-b06c46ec1d/unifi_sysvinit_all.deb'

Repair-UnifiPackage

You get a fixed package that no longer requires MongoDB 3.4 and can be installed with MongoDB 3.6. What's left is installing the Unifi package in the system. You then simply take the path where fixed unifi package is located and follow with the installation. Keep in mind the paths are random in the temp folder. They change on each run.

dpkg -i /tmp/cmjsbmswargce/unifi-package-fixed.db

dpkg -i unifi

And voila! We've got upgraded Unifi instance. As you can notice above I've downloaded 5.10.20 stable candidate first but decided it's better to go with Stable version instead.

Related Posts