PowerShell

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

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'

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

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.

This post was last modified on March 11, 2019 22:44

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

2 weeks ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

4 months ago

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

9 months ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

1 year ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

1 year ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

1 year ago