Installing Ubiquiti UniFi Controller in a jail

Installing Ubiquiti UniFi Controller in a jail

Baenwort

Explorer
Joined
Feb 19, 2015
Messages
93
Do I need to wipe out and reconfigure all of my jails or can I just wipe, make new, and restore this single jail?
 

Baenwort

Explorer
Joined
Feb 19, 2015
Messages
93
This almost certainly has to do with you having FreeBSD-10 based jails on a FreeBSD-11 based operating system.

OPtions that come to mind:

1) You could blow away your jails and make new FreeNAS-11 based jails.
2) You can see if someone else with a second opinion and a decent idea for doing this the "right" way without blowing away your jails shows up.
3) There is a "hack" in this thread that almost certainly will work, with the appropriate modification: https://forums.freenas.org/index.php?threads/trouble-update-ports-jail-after-9-10-upgrade.42250/

As a temp while I hope someone comes up with a better answer I used "setenv UNAME_r 10.3-Release" from your third suggestion to at least get the unifi controller in the jail updated for now.
 

vilane

Dabbler
Joined
May 6, 2015
Messages
32
Not sure if it's still necessary or not, but when unifi pulls in the mongodb package dependency, you may want/need to configure the default mongodb (not attached to unifi) to not autostart. This would then cull a second mongodb instance from running inside your jail and save you some resources (not that an empty db instance is going to consume a lot). below is what I used on a Pi, may need translation into FreeBSD for the NAS jail.

Code:
echo 'ENABLE_MONGODB=no' | sudo tee -a /etc/mongodb.conf > /dev/null
 

tgsekhar

Dabbler
Joined
Sep 25, 2017
Messages
11
I'm pretty sure that I am missing something and it's most likely the storage for the jails. I'm new at this and for the life of me cannot seem to make the storage and permissions of the jail to work for this install. I have done the steps as described 4 times and each time I am left with it being unable to find the required file or not being able to execute. Actually, I'm pretty sure that I am screwing up the storage portion and the permissions for the jail. Any and all help would be greatly appreciated in a small tutorial.
 

tgsekhar

Dabbler
Joined
Sep 25, 2017
Messages
11
I have a install I built for this https://github.com/TechButton/unifi-controller-freebsd-freenas currently setup to install 5.5.14, this will install snappy java as well. I wrote this to do upgrades as well, backs up your install and then restores the files after the upgrade. You can modify the file with the new version on the forums or I will keep updating this install, I try to get to it every few weeks.

Login with SSH to your FreeNAS (or alternatively go to shell in WebGUI)
type: 'jls' (without ' ' ) and take the note of the # of jail of your Unifi installation
type: jexec # csh' (where # is the number of the jail noted in last step)
type: fetch -o install-unifi.sh https://raw.githubusercontent.com/T...freenas/master/install-unifi/install-unifi.sh
type: chmod 755 install-unifi.sh
type: ./install-unifi.sh

Thank you very much for this. After beating my brains in with other options, I came across this and the install was a breeze. So much so that I installed it on my office server and moved my home controller on to that one. Has been working since this morning without a hitch.

Couple of questions...if I reboot FreeNAS after an update or whatever, will the controller come back up automatically or do I have to manually restart the service. Second, when there is an update to Unifi, what would be the method to get the latest stable release?

Once again, thank you very much for such a quick and simple method.
 
Last edited by a moderator:

NAS-Plus

Explorer
Joined
Apr 15, 2017
Messages
73
Nice job m0nkey! Very well done!
 

Candle

Dabbler
Joined
Aug 24, 2017
Messages
10
Anyone else having trouble accessing this controller through Unifi Cloud remotely? Also, 3 gigs for this jail seems like a lot, am I missing something?
 

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
Anyone else having trouble accessing this controller through Unifi Cloud remotely?
Can't say I use this feature, however I wouldn't be surprised that it doesn't work as it may require something not available in FreeBSD or included as part of the port.
Also, 3 gigs for this jail seems like a lot, am I missing something?
UniFi has a dependency on LLVM and OpenJDK. These two requirements alone push up the disk space requirements.
 

Candle

Dabbler
Joined
Aug 24, 2017
Messages
10
Thanks for the quick response. I guess it will teach me how to get Ubuntu running in a VM to load Unifi that way.
 

appoli

Dabbler
Joined
Mar 22, 2017
Messages
44
Anyone else having trouble accessing this controller through Unifi Cloud remotely? Also, 3 gigs for this jail seems like a lot, am I missing something?


I think I was able to access it when I first installed unifi a couple months back.
But as of late it’s been no dice....I kept seeing posts saying it was java so I updated all that stuff recently and still nothing.

My emby jail needs to be restarted daily and b/c of this I’m thinking there may be some networking issue? (Couple devices are also unable to access smb shares too....all of which worked fine in corral, when I first got FreeNAS).
I tried a nightly recently since it seems like the beta is almost good to go. Looks like a big change to smb and nothing could connect to the shares.... boo
 

cleansman

Cadet
Joined
Nov 21, 2017
Messages
6
Hi,

thanks for the tutorial, everything was working fine for me for the last couple of months, but now I am having problems with the update process.

I am getting the following error message:

Code:
Building new INDEX files... done.																								 
root@unifi:/ # cd /usr/ports/net-mgmt/unifi5																						
root@unifi:/usr/ports/net-mgmt/unifi5 # service unifi stop																		
unifi not running? (check /var/run/unifi/unifi.pid).																				
root@unifi:/usr/ports/net-mgmt/unifi5 # make reinstall clean																		
===>   unifi5-5.6.24 depends on file: /usr/local/sbin/pkg - found																 
===> Fetching all distfiles required by unifi5-5.6.24 for building																
===>  Extracting for unifi5-5.6.24																								
=> SHA256 Checksum OK for unifi5-5.6.24/UniFi.unix.zip.																			
===>  Patching for unifi5-5.6.24																									
/bin/rm -f /usr/ports/net-mgmt/unifi5/work/UniFi/lib/snappy-java-1.1.2.6.jar														
(cd /usr/ports/net-mgmt/unifi5/work/UniFi/lib && /bin/ln -s /usr/local/share/java/classes/snappy-java.jar snappy-java-1.1.2.6.jar)
===>  Configuring for unifi5-5.6.24																								
===>  Staging for unifi5-5.6.24																									
===>   unifi5-5.6.24 depends on package: mongodb>0 - found																		
===>   unifi5-5.6.24 depends on package: snappyjava>0 - found																	 
===>   unifi5-5.6.24 depends on file: /usr/local/openjdk8/bin/java - found														
===>   Generating temporary packing list																							
===> Creating groups.																											 
===> Creating users																												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi													
(cd /usr/ports/net-mgmt/unifi5/work/UniFi && /bin/sh -c '(/usr/bin/find -Ed $1 $3 | /usr/bin/cpio -dumpl $2 >/dev/null 2>&1) &&  /us
r/bin/find -Ed $1 $3 \(   -type d -exec /bin/sh -c '\''cd '\''$2'\'' && chmod 755 "$@"'\'' . {} +  -o -type f -exec /bin/sh -c '\''c
d '\''$2'\'' && chmod 0644 "$@"'\'' . {} + \)' COPYTREE_SHARE \* /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi/)
/bin/ln -sf /usr/local/bin/mongod /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi/bin/mongod					 
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/data												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/logs												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/run												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/work												
====> Compressing man pages (compress-man)																						
===> Staging rc.d startup script(s)																								
===>  Installing for unifi5-5.6.24																								
===>   Registering installation for unifi5-5.6.24																				 
*** Error code 70																												 
																																 
Stop.																															 
make[1]: stopped in /usr/ports/net-mgmt/unifi5																					
*** Error code 1																													
																																 
Stop.																															 
make: stopped in /usr/ports/net-mgmt/unifi5																						
root@unifi:/usr/ports/net-mgmt/unifi5 #						 


Any idea what I can do to fix this?

Thanks!

cleansman
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Hi,

thanks for the tutorial, everything was working fine for me for the last couple of months, but now I am having problems with the update process.

I am getting the following error message:

Code:
Building new INDEX files... done.																								
root@unifi:/ # cd /usr/ports/net-mgmt/unifi5																						
root@unifi:/usr/ports/net-mgmt/unifi5 # service unifi stop																		
unifi not running? (check /var/run/unifi/unifi.pid).																				
root@unifi:/usr/ports/net-mgmt/unifi5 # make reinstall clean																		
===>   unifi5-5.6.24 depends on file: /usr/local/sbin/pkg - found																
===> Fetching all distfiles required by unifi5-5.6.24 for building																
===>  Extracting for unifi5-5.6.24																								
=> SHA256 Checksum OK for unifi5-5.6.24/UniFi.unix.zip.																			
===>  Patching for unifi5-5.6.24																									
/bin/rm -f /usr/ports/net-mgmt/unifi5/work/UniFi/lib/snappy-java-1.1.2.6.jar														
(cd /usr/ports/net-mgmt/unifi5/work/UniFi/lib && /bin/ln -s /usr/local/share/java/classes/snappy-java.jar snappy-java-1.1.2.6.jar)
===>  Configuring for unifi5-5.6.24																								
===>  Staging for unifi5-5.6.24																									
===>   unifi5-5.6.24 depends on package: mongodb>0 - found																		
===>   unifi5-5.6.24 depends on package: snappyjava>0 - found																	
===>   unifi5-5.6.24 depends on file: /usr/local/openjdk8/bin/java - found														
===>   Generating temporary packing list																							
===> Creating groups.																											
===> Creating users																												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi													
(cd /usr/ports/net-mgmt/unifi5/work/UniFi && /bin/sh -c '(/usr/bin/find -Ed $1 $3 | /usr/bin/cpio -dumpl $2 >/dev/null 2>&1) &&  /us
r/bin/find -Ed $1 $3 \(   -type d -exec /bin/sh -c '\''cd '\''$2'\'' && chmod 755 "$@"'\'' . {} +  -o -type f -exec /bin/sh -c '\''c
d '\''$2'\'' && chmod 0644 "$@"'\'' . {} + \)' COPYTREE_SHARE \* /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi/)
/bin/ln -sf /usr/local/bin/mongod /usr/ports/net-mgmt/unifi5/work/stage/usr/local/share/java/unifi/bin/mongod					
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/data												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/logs												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/run												
/bin/mkdir -p /usr/ports/net-mgmt/unifi5/work/stage//usr/local/share/java/unifi/work												
====> Compressing man pages (compress-man)																						
===> Staging rc.d startup script(s)																								
===>  Installing for unifi5-5.6.24																								
===>   Registering installation for unifi5-5.6.24																				
*** Error code 70																												
																																
Stop.																															
make[1]: stopped in /usr/ports/net-mgmt/unifi5																					
*** Error code 1																													
																																
Stop.																															
make: stopped in /usr/ports/net-mgmt/unifi5																						
root@unifi:/usr/ports/net-mgmt/unifi5 #						


Any idea what I can do to fix this?

Thanks!

cleansman
try make deinstall reinstall all clean
 

cleansman

Cadet
Joined
Nov 21, 2017
Messages
6
Wow, thanks for the quick reply.

This worked like a charm:

Code:
root@unifi:/usr/ports/net-mgmt/unifi5 # make deinstall reinstall all clean														
===>  Deinstalling for unifi5																									 
===>   Deinstalling unifi5-5.5.24																								 
Checking integrity... done (0 conflicting)																						
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):									
																																 
Installed packages to be REMOVED:																								 
	   unifi5-5.5.24																											 
																																 
Number of packages to be removed: 1																								
																																 
The operation will free 201 MiB.																									
[unifi] [1/1] Deinstalling unifi5-5.5.24...																						
[unifi] [1/1] Deleting files for unifi5-5.5.24: 100%																				
==> You should manually remove the "unifi" user.																					
==> You should manually remove the "unifi" group																					
===>  Installing for unifi5-5.6.24																								
===>   unifi5-5.6.24 depends on package: mongodb>0 - found																		
===>   unifi5-5.6.24 depends on package: snappyjava>0 - found																	 
===>   unifi5-5.6.24 depends on file: /usr/local/openjdk8/bin/java - found														
===>   Registering installation for unifi5-5.6.24																				 
[unifi] Installing unifi5-5.6.24...																								
===> Creating groups.																											 
Using existing group 'unifi'.																									 
===> Creating users																												
Using existing user 'unifi'.																										
echo: write error on stdout																										
===>  Cleaning for unifi5-5.6.24																									
root@unifi:/usr/ports/net-mgmt/unifi5 # service unifi start																		
Starting unifi.																													
root@unifi:/usr/ports/net-mgmt/unifi5 #


Thank you very much!

cleansman
 
Last edited:

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
I suggest making a script in your jail and use that to update.
Code:
#!/bin/sh																														   
																																   
portsnap fetch update && cd /usr/ports/net-mgmt/unifi5/ && make deinstall reinstall clean && service unifi restart
 

AVSION

Contributor
Joined
Dec 28, 2016
Messages
128
Hi, after update to v 5.6.24 i get an error STUN Communication failed on all my sites, i checked port 3478 and its still closed. this port was closed in v 5.5.20 and other older versions but i didn't get that error. also i did open this port on my ERL router long time ago but when i checked it always showed closed. can you please let me know how to fix this error?

EDIT: ports 8080,8443,8880,8843 are all open when i test them
 
Last edited:

tgsekhar

Dabbler
Joined
Sep 25, 2017
Messages
11
I suggest making a script in your jail and use that to update.
Code:
#!/bin/sh																														  
																																  
portsnap fetch update && cd /usr/ports/net-mgmt/unifi5/ && make deinstall reinstall clean && service unifi restart

Worked like a charm! Many, many thanks.
 

Icy1211

Cadet
Joined
Oct 28, 2014
Messages
2
Anyone else having trouble accessing this controller through Unifi Cloud remotely? Also, 3 gigs for this jail seems like a lot, am I missing something?

I can't get Unifi Cloud access working either with this jail install. Anyone have any ideas? I heard one way to get is to do VM ware with Ubuntu instead.
 

WayneC1972

Dabbler
Joined
Oct 19, 2015
Messages
22
I got this error. Any assistance would be appreciated.

root@unifi:/usr/ports/net-mgmt/unifi5 # make install clean BATCH=yes
/!\ ERROR: /!\

Ports Collection support for your FreeBSD version has ended, and no ports are
guaranteed to build on this system. Please upgrade to a supported release.

No support will be provided if you silence this message by defining
ALLOW_UNSUPPORTED_SYSTEM.

*** Error code 1

Stop.
make: stopped in /usr/ports/net-mgmt/unifi5
root@unifi:/usr/ports/net-mgmt/unifi5 #
 

ThreeDee

Guru
Joined
Jun 13, 2013
Messages
698
getting the same error and now cant reinstall :(
 
Top