Ubuntu

Ubuntu 18.04 – Fixing Unifi .deb package to run with 3.6 mongodb

If you don't know I am a huge fan of Ubiquiti and UNIFI. Since some time I've been running on Unifi 5.9.X alpha/beta versions and one problem it has is that it specifies you need MongoDB on version 3.4. Unfortunately with Ubuntu 18.04 that's no longer the case. So if you try to install package it will complain and tell you that your MongoDB version is too high. You can of course overwrite it by telling dpkg to ignore dependencies and so I did and I'm happy user of Unifi 5.9.x. The problem with this approach is that when you do that next time you try to update your system (not Unifi) you will get an error that Unifi can't upgrade and so any updates to your system are denied until you fix them.

root@EvoWebsites:/home/pklys# apt update
Hit:1 http://ppa.launchpad.net/ondrej/apache2/ubuntu bionic InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Hit:3 http://pl.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://pl.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main Sources [51.0 kB]
Get:6 http://pl.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [179 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [141 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [69.7 kB]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages [85.1 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [85.2 kB]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [46.8 kB]
Get:13 http://pl.archive.ubuntu.com/ubuntu bionic-updates/main Sources [193 kB]
Get:14 http://pl.archive.ubuntu.com/ubuntu bionic-updates/universe Sources [87.5 kB]
Get:15 http://pl.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [396 kB]
Get:16 http://pl.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [356 kB]
Get:17 http://pl.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [147 kB]
Get:18 http://pl.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [3,616 B]
Get:19 http://pl.archive.ubuntu.com/ubuntu bionic-updates/restricted i386 Packages [3,580 B]
Get:20 http://pl.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [558 kB]
Get:21 http://pl.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [553 kB]
Get:22 http://pl.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [144 kB]
Get:23 http://pl.archive.ubuntu.com/ubuntu bionic-updates/multiverse i386 Packages [5,520 B]
Get:24 http://pl.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [5,372 B]
Fetched 3,358 kB in 1s (4,131 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
167 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@EvoWebsites:/home/pklys# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 unifi : Depends: mongodb-server (< 1:3.6.0) but 1:3.6.3-0ubuntu1 is installed or
                  mongodb-10gen (< 3.6.0) but it is not installable or
                  mongodb-org-server (< 3.6.0) but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

That's very unfortunate drawback and caused me to consider downgrading MongoDB to 3.4 or search for alternative solutions. And at this point there are many solutions on Unifi forums telling you how to install/use MongoDB 3.4 on newest Ubuntu system. But for me this would mean I would have to uninstall Unifi, fix MongoDB, reinstall… just too many steps. And after all my Unifi works just fine on MongoDB 3.6!

Fixing Unifi Package Automatically
Since this is a process that has to be repeated over and over again, I decided to write a short PowerShell module that fixes it each time for you. There's another blog post about it. I know you may not like PowerShell being installed on Linux but it works just fine, and it's something I'm skilled at. Easy to use, works on all platforms. What's not to love?

That's why I've chosen a bit different approach. Why fix Ubuntu, while I can fix Unifi package! And it's actually quite simple…

Steps to fix Unifi package
Download new Unifi package
Unpack .deb package
Edit control file
Remove 2 lines
Pack .deb package again

And that's it! Easier said then done you say… well here it is… a simple step by step.

cd /home/username
mkdir tmp
cd tmp
wget https://dl.ubnt.com/unifi/5.9.29/unifi_sysvinit_all.deb
mkdir temporary
dpkg-deb -R unifi_sysvinit_all.deb temporary

Now edit control file which should be in unpacked directory inside DEBIAN folder. It's content will look like this. I've marked the lines that needs removing

Package: unifi
Version: 5.9.29-11384-1
Section: java
Priority: optional
Architecture: all
Depends: binutils, coreutils, adduser, libcap2, curl,
 mongodb-server (>= 2.4.10) | mongodb-10gen (>= 2.4.14) | mongodb-org-server (>= 2.6.0),
 mongodb-server (<< 1:3.6.0) | mongodb-10gen (<< 3.6.0) | mongodb-org-server (<< 3.6.0),
 java8-runtime-headless, jsvc (>=1.0.8)
Pre-Depends: debconf (>= 0.5) | debconf-2.0
Conflicts: unifi-controller
Provides: unifi-controller
Replaces: unifi-controller
Installed-Size: 143115
Maintainer: UniFi developers <unifi-dev@ubnt.com>
Description: Ubiquiti UniFi server
 Ubiquiti UniFi server is a centralized management system for UniFi suite of devices.
 After the UniFi server is installed, the UniFi controller can be accessed on any
 web browser. The UniFi controller allows the operator to instantly provision thousands
 of UniFi devices, map out network topology, quickly manage system traffic, and further
 provision individual UniFi devices.
Homepage: http://www.ubnt.com/unifi

After removing those 2 lines you must repackage unifi.deb.

root@EvoWebsites:/home/pklys/tmp# dpkg-deb -b temporary unifi-fixed.deb
dpkg-deb: building package 'unifi' in 'unifi-fixed.deb'.

Now all that is left is try if the Unifi package actually installs over currently installed one!

root@EvoWebsites:/home/pklys/tmp# dpkg -i unifi-fixed.deb
(Reading database ... 135659 files and directories currently installed.)
Preparing to unpack unifi-fixed.deb ...
Previous setting (UniFi 5.9.29) is found.
Unpacking unifi (5.9.29-11384-1) over (5.9.29-11384-1) ...
Setting up unifi (5.9.29-11384-1) ...
Processing triggers for systemd (237-3ubuntu10) ...
Processing triggers for ureadahead (0.100.0-20) ...
root@EvoWebsites:/home/pklys/tmp#

After that… simply rerun apt update, apt-upgrade and it will work!

root@EvoWebsites:/home/pklys/tmp# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-4.15.0-36 linux-headers-4.15.0-36-generic linux-image-4.15.0-36-generic linux-modules-4.15.0-36-generic linux-modules-extra-4.15.0-36-generic
The following packages will be upgraded:
  amd64-microcode apache2 apache2-bin apache2-data apache2-utils apparmor apport apt apt-transport-https apt-utils base-files bind9-host binutils binutils-common
  binutils-x86-64-linux-gnu ca-certificates-java console-setup console-setup-linux cpp cpp-7 curl dnsutils gcc gcc-7 gcc-7-base gcc-8-base grub-common grub-pc
  grub-pc-bin grub2-common initramfs-tools initramfs-tools-bin initramfs-tools-core intel-microcode keyboard-configuration libapparmor-perl libapparmor1
  libapt-inst2.0 libapt-pkg5.0 libasan4 libatomic1 libavahi-client3 libavahi-common-data libavahi-common3 libbind9-160 libbinutils libbrotli1 libcc1-0 libcilkrts5
  libcryptsetup12 libcurl3-gnutls libcurl4 libdns-export1100 libdns1100 libegl1 libgcc-7-dev libgcc1 libgd3 libgl1 libglib2.0-0 libglib2.0-data libglvnd0 libglx0
  libgomp1 libgpgme11 libirs160 libisc-export169 libisc169 libisccc160 libisccfg160 libitm1 liblcms2-2 liblsan0 liblwres160 libmpx2 libnss-systemd libpam-systemd
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libperl5.26 libplymouth4 libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libpython3-stdlib
  libpython3.6 libpython3.6-minimal libpython3.6-stdlib libquadmath0 libstdc++6 libsystemd0 libtsan0 libubsan0 libudev1 libx11-6 libx11-data libx11-dev libx11-doc
  libx11-xcb1 libxml2 linux-generic linux-headers-generic linux-image-generic linux-libc-dev lshw mutt mysql-client-5.7 mysql-client-core-5.7 mysql-server
  mysql-server-5.7 mysql-server-core-5.7 netplan.io nplan openjdk-11-jre-headless openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless perl
  perl-base perl-modules-5.26 php7.2 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache
  php7.2-readline php7.2-xml php7.2-xmlrpc plymouth plymouth-theme-ubuntu-text policykit-1 python-apt python-apt-common python-cryptography python3 python3-apport
  python3-apt python3-cryptography python3-distupgrade python3-minimal python3-problem-report python3-software-properties python3-update-manager python3.6
  python3.6-minimal rkhunter screen snapd software-properties-common squashfs-tools systemd systemd-sysv tzdata ubuntu-release-upgrader-core udev
  unattended-upgrades update-manager-core wpasupplicant x11-common
167 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 243 MB of archives.
After this operation, 337 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Fixing Unifi Package Automatically
Since this is a process that has to be repeated over and over again, I decided to write a short PowerShell module that fixes it each time for you. There's another blog post about it. I know you may not like PowerShell being installed on Linux but it works just fine, and it's something I'm skilled at. Easy to use, works on all platforms. What's not to love?

And we're done. Unifi 5.9.29 on Ubuntu 18.04 with MongoDB higher then 3.4 version and no complains from APT!

This post was last modified on 11 marca, 2019 22:35

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…

5 dni 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 miesiące 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…

8 miesięcy 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 rok 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 rok 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 rok ago