Unifi Jail Creation while storing config/data on Dataset

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
I'm a newbie, but I'm trying to figure this TrueNas thing out. I've so far installed plex and transmission, by following some of the "Resources" on this site. I have a dataset created for each of apps, and have their configs (at least I think) stored on the dataset as I heard this is the best thing to do to make recovery easier should I have to nuke a jail.

Now I couldn't find a resource to install Unifi6 on TrueNas 12. So I duct taped a solution from numerous threads on how to install other jails. This is what I came up with:

Code:
root@TrueNAS[~]# echo '{"pkgs":["bash","unifi6"]}' > /tmp/pkg.json
root@TrueNAS[~]# iocage create -n "unifi" -p /tmp/pkg.json -r 12.2-RELEASE ip4_addr="vnet0|192.168.1.200/24" defaultrouter="192.168.1.1" vnet="on" boot="on" host_hostname="uniFi"
unifi successfully created!

Testing Host DNS response to pkg.freebsd.org
Testing unifi's SRV response to pkg.freebsd.org
Testing unifi's DNSSEC response to pkg.freebsd.org

Installing pkg...
You may need to manually remove /usr/local/etc/pkg.conf if it is no longer needed.

Installing supplied packages:
  - bash...
  - unifi6...
*** Added group `cyrus' (id 60)
*** Added user `cyrus' (id 60)
===> Creating groups.
Creating group 'mongodb' with gid '922'.
===> Creating users
Creating user 'mongodb' with uid '922'.
===> Creating homedir(s)
===> Creating groups.
Creating group 'unifi' with gid '975'.
===> Creating users
Creating user 'unifi' with uid '975'.
=====
Message from freetype2-2.10.4:

--
The 2.7.x series now uses the new subpixel hinting mode (V40 port's option) as
the default, emulating a modern version of ClearType. This change inevitably
leads to different rendering results, and you might change port's options to
adapt it to your taste (or use the new "FREETYPE_PROPERTIES" environment
variable).

The environment variable "FREETYPE_PROPERTIES" can be used to control the
driver properties. Example:

FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
        cff:no-stem-darkening=1 \
        autofitter:warping=1

This allows to select, say, the subpixel hinting mode at runtime for a given
application.

If LONG_PCF_NAMES port's option was enabled, the PCF family names may include
the foundry and information whether they contain wide characters. For example,
"Sony Fixed" or "Misc Fixed Wide", instead of "Fixed". This can be disabled at
run time with using pcf:no-long-family-names property, if needed. Example:

FREETYPE_PROPERTIES=pcf:no-long-family-names=1

How to recreate fontconfig cache with using such environment variable,
if needed:
# env FREETYPE_PROPERTIES=pcf:no-long-family-names=1 fc-cache -fsv

The controllable properties are listed in the section "Controlling FreeType
Modules" in the reference's table of contents
(/usr/local/share/doc/freetype2/reference/site/index.html, if documentation was installed).
=====
Message from dejavu-2.37_1:

--
Make sure that the freetype module is loaded.  If it is not, add the following
line to the "Modules" section of your X Windows configuration file:

        Load "freetype"

Add the following line to the "Files" section of X Windows configuration file:

        FontPath "/usr/local/share/fonts/dejavu/"

Note: your X Windows configuration file is typically /etc/X11/XF86Config
if you are using XFree86, and /etc/X11/xorg.conf if you are using X.Org.
=====
Message from libinotify-20180201_2:

--
Libinotify functionality on FreeBSD is missing support for

  - detecting a file being moved into or out of a directory within the
    same filesystem
  - certain modifications to a symbolic link (rather than the
    file it points to.)

in addition to the known limitations on all platforms using kqueue(2)
where various open and close notifications are unimplemented.

This means the following regression tests will fail:

Directory notifications:
   IN_MOVED_FROM
   IN_MOVED_TO

Open/close notifications:
   IN_OPEN
   IN_CLOSE_NOWRITE
   IN_CLOSE_WRITE

Symbolic Link notifications:
   IN_DONT_FOLLOW
   IN_ATTRIB
   IN_MOVE_SELF
   IN_DELETE_SELF

Kernel patches to address the missing directory and symbolic link
notifications are available from:

https://github.com/libinotify-kqueue/libinotify-kqueue/tree/master/patches

You might want to consider increasing the kern.maxfiles tunable if you plan
to use this library for applications that need to monitor activity of a lot
of files.
=====
Message from alsa-lib-1.2.2:

--
===>   NOTICE:

The alsa-lib port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://docs.freebsd.org/en/articles/contributing/#ports-contributing
=====
Message from openjdk8-8.292.10.1:

--
This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
procfs(5) mounted on /proc.

If you have not done it yet, please do the following:

        mount -t fdescfs fdesc /dev/fd
        mount -t procfs proc /proc

To make it permanent, you need the following lines in /etc/fstab:

        fdesc   /dev/fd         fdescfs         rw      0       0
        proc    /proc           procfs          rw      0       0
=====
Message from cyrus-sasl-2.1.27_1:

--
You can use sasldb2 for authentication, to add users use:

        saslpasswd2 -c username

If you want to enable SMTP AUTH with the system Sendmail, read
Sendmail.README

NOTE: This port has been compiled with a default pwcheck_method of
      auxprop.  If you want to authenticate your user by /etc/passwd,
      PAM or LDAP, install ports/security/cyrus-sasl2-saslauthd and
      set sasl_pwcheck_method to saslauthd after installing the
      Cyrus-IMAPd 2.X port.  You should also check the
      /usr/local/lib/sasl2/*.conf files for the correct
      pwcheck_method.
      If you want to use GSSAPI mechanism, install
      ports/security/cyrus-sasl2-gssapi.
      If you want to use SRP mechanism, install
      ports/security/cyrus-sasl2-srp.
      If you want to use LDAP auxprop plugin, install
      ports/security/cyrus-sasl2-ldapdb.
=====
Message from boost-libs-1.72.0_5:

--
You have built the Boost library with thread support.

Don't forget to add -pthread to your linker options when
linking your code.
No default gateway found for ipv6.
* Starting unifi
  + Started OK
  + Using devfs_ruleset: 1002 (iocage generated default)
  + Configuring VNET OK
  + Using IP options: vnet
  + Starting services OK
  + Executing poststart OK
root@TrueNAS[~]# rm /tmp/pkg.json
root@TrueNAS[~]# iocage fstab -a unifi /mnt/tank/turret/unifi /usr/local/share/java/unifi/data/ nullfs rw 0 0
Successfully added mount to unifi's fstab
root@TrueNAS[~]# iocage exec unifi sysrc unifi_enable="Yes"
unifi_enable:  -> Yes
root@TrueNAS[~]# iocage exec unifi service unifi start
Starting unifi.
root@TrueNAS[~]#


So here is where I need help:
1) Is this the right process? Did I miss anything that I needed to do in the setup of the jail?
2) The problem is the data file for unifi is never created. If I don't create the mount point the files are created and everything is fine, however, I don't have anything stored on my "app" dataset in the unifi directory. How do I fix this so that the config is created as normal, and i get a backup in my unifi dataset?

Thank you in advance.
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
Ok I figured it out, I believe I forgot this line:
Code:
iocage exec unifi chown -R unifi:unifi /usr/local/share/java/unifi/data/


I did that restarted the jail and it is now creating the directories and they are being written.

My question now is: Does this give me the stated purpose of backing up the configs? My concern is when I shut down the jail, don't those files disappear with the jail?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
It seems it would be much easier to install unifi6 via pkg and do a databse backup via the gui rather than the complicated setup you have going.
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
Isn't that basically what I did?

The only difference is I would have to login to the gui (weekly or monthly) to backup the server and save the files to another computer. It seems easier to me to have the autobackup create the files in another dataset, safe in case I need to nuke the jail.

Am I missing something here? I've read so many posts on this in my move to TrueNAS about keeping config outside of the jail in their own datasets. I thought that was what I was doing?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Are you planning on making constant changes to your network configuration? I just don't see why you would need frequent backups of your unifi settings. It's one of those things that once it's set up you don't really need to do anything to it unless you are making changes. And if you're making changes you'll already be in the GUI so just make a manual backup before you log out.

Having said that, don't let me deter you on doing what you want with your setup. This is just my opinion on it and you can run your setup any way you like.
 

ThreeDee

Guru
Joined
Jun 13, 2013
Messages
700
as Jailer said .. you can just backup your config to your PC or wherever via the web gui
i.e .... backup_6.2.26_20210714_1346.unf

.. but, it's your setup .. set it up however you want, lol.

isn't it just
Code:
pkg install unifi6
sysrc unifi_enable=YES
service unifi start


..and then log into whatever IP you set your jail to and restore from your ***.unf file .. or start anew ..?
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
Are you planning on making constant changes to your network configuration? I just don't see why you would need frequent backups of your unifi settings. It's one of those things that once it's set up you don't really need to do anything to it unless you are making changes. And if you're making changes you'll already be in the GUI so just make a manual backup before you log out.

Having said that, don't let me deter you on doing what you want with your setup. This is just my opinion on it and you can run your setup any way you like.


as Jailer said .. you can just backup your config to your PC or wherever via the web gui
i.e .... backup_6.2.26_20210714_1346.unf

.. but, it's your setup .. set it up however you want, lol.[/code]

While I understand your comments, I feel they take a very superficial look at the request. I would like to have my config backed up without my interaction or me having to do something every time I need it done. It would be like telling me to not schedule a snapshot or rysnc task, but instead just use the GUI. While that might work, that is also why people don't have backups and lose their data.

While my use case may not fit yours, I will give you some insight into why having a backup outside of the jail is beneficial to me (at least I think) and might be for others.

First while I don't make "constant changes" I do make changes at least 1-2 times per month, and I currently do so on my cell phone via the app. Keeping configs on my phone is not ideal for me, but making quick changes in the app is.
As it stands right now I have 4 controllers each running on a raspberry pi at 4 different locations (home, vacation rental, parent's house, in-laws house) with 13 APs combined. I am looking to condense these into one controller with multiple sites, connected via VPN to my pfsense box here at my home. In this case I can block things like P2P, warez, torrents, guests, etc, and troubleshoot from my TrueNas box. I do not want to lose any info such as block lists, access times, guest logs, etc. I've had these APs working for over 6 years and that is a wealth of statistical information I would prefer not to lose. So what better place than to back this up to my NAS box, automatically, which has enough space to house a backup every day for the next 100 years if I wanted to? Then if I have to start the jail over, I accidentally destroy it in my ignorance, or it becomes corrupt because of an upgrade, I still have my backups secure on the NAS.

I guess I might be missing something though as you both seem like verterans at this TrueNAS. Maybe this setup doesn't afford me that protection and is worthless, if so that's what I need to know.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Your explanation does make me look at this a bit differently, I never considered someone managing the controller with a phone.

Set up autoconfig backups in the unifi controller GUI. Then just set up a scheduled rsync task in TrueNAS to copy the contents of the auto config backup directory to another dataset of your choosing.

The directory for the backups is usr/local/share/java/unifi/data/backup/autobackup It should be as simple as that.
 
Top