Installing Ubiquiti UniFi Controller in a jail

Installing Ubiquiti UniFi Controller in a jail

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
@UnifiUpdate --
ports -- tree where you build programs and dependencies from source. Usually ports tree has newer releases soon after the sources are released. Advantage is usually there are newer packages, however there is definitely a lot more potential problems with dependencies and oftentimes the program won't compile. Sometimes when things compile the process could be long -- like several hours.

pkg - FreeBSD maintainers have already done the hard work and have compiled the program. Usually pkgs are a little bit behind the ports tree, however pkgs usually install without any issues. Sometimes there are dependency problems, and if this occurs the pkgs will lag behind ports for possibly sometime until either the source or pkg container figures things out. Pkgs install quick but they possibly may be older versions. You may also want to make sure that the pkg source -- you're pulling from latest rather than the quarterly branch. This is an ABI setting. pkg -vv will tell you what branch you are pulling from. This post here kind of explains what I'm talking about: https://forums.freebsd.org/threads/is-freebsd-pkg-command-pointing-to-latest-repository.67571/

As a general rule -- unless you are a developer or you actually need --- I mean really need -- the new capabilities in the newer releases, I'd almost always recommend sticking with the pkg install method. It's almost foolproof. I'm not sure what youre doing with your unifi controller software -- however often with mine I set it up, tinker, and then kind of forget about it. I can't say I hunt the latest and greatest features for this utility.
 

UnifiUpdate

Cadet
Joined
Sep 27, 2019
Messages
2
Thanks a lot @KevDog. That helped me figure it out. Indeed, I was using the default `quarterly`. After switching to `latest` the newer unifi5 showed up.
 

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
@UnifUpdate -- Some other things you might want to consider -- I'll probably receive a lot of bad comments for this -- but something to consider.
Jails are great -- until they aren't.
When I was on FreeNAS version 9.4 (I think that was the version) and then FreeNas updated to 10, then pulled the update and then went immediately to version 11 -- the base version of FreeBSD was upgraded on the main install. Although I upgraded FreeNAS from 9.4->11.0 the jails were still on the FreeBSD version of 9.4 and not 11 (jails don't upgrade with the main system). I found I couldn't update any of the packages and in the end I ended up just recreating the jails. I think that is still the recommended advice -- recreate the jails with any major FreeBSD upgrade. I can't tell you how much a pain this is!!! Based on this experience, I keep things running in jails pretty simple -- meaning if I had to recreate the jail -- I could do it fairly quick since I don't install a bunch of packages inside the jail. If anything requires a ton of package installing and tweaking, I personally switched from using jails to VMs. Although VMs need updating as well, maybe I've been lucky, but I haven't been in a situation where I've had to reinstall everything and start from scratch.

I have no idea how easy it is to configure the Unifi software -- I just bought a Gen2 controller -- and use the hardware/software combination for my network. It seems installing the unifi software from pkg is a fairly simple setup -- and as long as you can export/import the settings for the controller easily, I'd say you're pretty future proof for future FreeBSD upgrades.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,974
I think that is still the recommended advice -- recreate the jails with any major FreeBSD upgrade.
Not since the switch to iocage. With Iocage you can upgrade the jail version without having to recreate the jail. You still can not have your jails on a version newer than the host so the jail upgrade has to keep pace with the host version of FreeBSD.
 

KevDog

Patron
Joined
Nov 26, 2016
Messages
462
@Jailer -- good information -- that's awesome and a great feature.
 

msbxa

Contributor
Joined
Sep 21, 2014
Messages
151
This method does install Unifi controller without any errors but you can't access it like it doesn't exists. i haven't used iocage jails and also running on FreeNAS 11.1 U7. Unless i am missing something which I am not sure what. one more question to install Unifi do you need to start the install here:
cd /usr/ports/net-mgmt/unifi5 ?

This is where I start the install:
root@PRODNAS2:~ # jexec 16
root@Unifi5:/ # pkg update
t's now pretty simple to install the UniFi controller. It's four simple steps!​
Code:​
pkg update​
pkg install unifi5​
sysrc unifi_enable=YES​
service unifi start​
That's it!​
Update: the above methods works with FreeNAS 11.2 U6 on iocage jails​
 
Last edited:

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,974

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,974
Also do note that if you are still on FreeNAS 11.1 it is based on a version of FreeBSD that is no longer supported and uses Warden as the jails manager which is deprecated. You really should upgrade and switch to using iocage for your jails.
 

msbxa

Contributor
Joined
Sep 21, 2014
Messages
151
Also do note that if you are still on FreeNAS 11.1 it is based on a version of FreeBSD that is no longer supported and uses Warden as the jails manager which is deprecated. You really should upgrade and switch to using iocage for your jails.

I upgrade my FreeNAS from 11.1 U7 to 11.2 U6 last 4 days and my Unifi was running on it with iocage but yesterday suddenly couldn't be able to log into Webgui and used every technical knowledge i had couldn't be able resolve it. So last option was to restore back to FreeNAS 11.1 U7 and happy to say i am back.

This was my problem: I end up reseting my configuration to defaults still didn't work. i am still investigating before I jump to 11.2.
The following alert has been cleared:
* The web interface could not bind to 192.168.1.3; using 0.0.0.0
 

ChrisChros

Patron
Joined
Nov 24, 2018
Messages
218
How did you switch to unifi5 Latest on FreeNAS ?
As discribed in the main thread:
  • SSH to your FreeNAS box and run: jexec <jailname> csh
  • Update ports: portsnap fetch extract
  • Change to directory /usr/ports/net-mgmt/unifi5
  • Stop UniFi: service unifi stop
  • Build and re-install: make reinstall clean
  • Start UniFi: service unifi start
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,456
Is there a possibility to edit the config.gateway.json file within the jail?
Of course, it's an ordinary FreeBSD filesystem. You'll just need to locate the appropriate directory for it (I'd guess it would be somewhere under /usr/local/).
 

ChrisChros

Patron
Joined
Nov 24, 2018
Messages
218
The path to the config.gateway.json file within the jail is:
/mnt/Pool where the controller is installed/iocage/jails/Jail name of the controller/root/usr/local/share/java/unifi/data/sites/default
 

msbxa

Contributor
Joined
Sep 21, 2014
Messages
151
FYI, latest pkg for UniFi Network Controller 5.11.46 is available. pkg install unifi5
Don't forget to make Unifi configuration backup before you install any new pkg.
 

tadeus

Dabbler
Joined
Aug 29, 2019
Messages
29
Thank you for this easy way to install unificontroller to a jail. That works fine.

I'm new at freenas and I have a question about the update things of this pkg package. I want to use a backup from a unificontroller 5.11.50 but the freenas unificontroller is version 5.11.46.
Can I only wait till the pkg version of the unifi package is available and the package get an automatic update? (like i know from different linux distributions)
Or should I look every day with "pkg update/upgrade" if there is a new version available? (How many days will it take usually?)
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,456
Or should I look every day with "pkg update/upgrade"
  • There's no need to do both pkg update and pkg upgrade; pkg isn't apt. pkg upgrade is fine.
  • Periodically checking is really the only way to know when it's ready. I'd expect it to be there in a week or two, but really it'll be there when it's there.
 

tadeus

Dabbler
Joined
Aug 29, 2019
Messages
29
Thank you.
For the future, is it recommended to look frequently for pkg upgrade or is there an automatism which will do that work?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,974
Thank you for this easy way to install unificontroller to a jail. That works fine.

I'm new at freenas and I have a question about the update things of this pkg package. I want to use a backup from a unificontroller 5.11.50 but the freenas unificontroller is version 5.11.46.
Can I only wait till the pkg version of the unifi package is available and the package get an automatic update? (like i know from different linux distributions)
Or should I look every day with "pkg update/upgrade" if there is a new version available? (How many days will it take usually?)
It's available now.
 
Top