I realize that the subject by itself seems to limit the interested audience of this post significantly. It took some tweaks to get the UniFi Controller from Ubiquiti working on Arch Linux | ARM though and I wanted to get it out there, if only just for me.
I’m going to presume you already have Arch Linux running on ARM. I used a Raspberry Pi 2, so your packages/mileage may vary if you are following these instructions elsewhere. Your users should have sudo privileges, otherwise you should su and then ignore the sudo part of each command. First, lets install the packages we need:
sudo pacman -S mongodb jdk7-openjdk unzip
These are the only dependencies required for the controller. With that done, you can download and extract the unix zip file from the UniFi Download Page. It will be named something like UniFi vX.X.X Zip for DIY. Mine looked something like this:
wget http://dl.ubnt.com/unifi/4.7.6/UniFi.unix.zip unzip UniFi.unix.zip sudo mv UniFi /opt/UniFi
By default, UniFi has a symlink to mongod but we need to add a few options to get mongod to startup through the controller. The reason behind the two additional options is primarily due to the Raspberry Pi 2 being 32-bit and MongoDB having some limitations on it.
cd /opt/UniFi/bin/ cat >mongod #!/bin/bash /usr/bin/mongod --journal --storageEngine=mmapv1 "$@" ^D chmod a+x mongod
You can now create a service to start and stop it. Here is my service file:
cat /lib/systemd/system/unifi.service [Unit] Description=unifi After=local-fs.target remote-fs.target network-online.target Wants=network-online.target Conflicts=shutdown.target [Service] TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process RemainAfterExit=yes ExecStart=/usr/bin/java -jar /opt/UniFi/lib/ace.jar start ExecStop=/usr/bin/java -jar /opt/UniFi/lib/ace.jar stop [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable unifi sudo systemctl start unifi
It may take a few minutes to start up but the web app should eventually be available. I’ve had several restarts with my pi2 and it’s always come up fine. For more information on starting and stopping, you can see the readme.txt file that came with the zip.
There are a couple of things it mentions that the unix version isn’t able to do, namely upgrade and backup. Upgrading basically involves taking a backup, getting the new zip file and overlaying it, and then restoring the backup. I haven’t had to do this yet, but I was interested to know if/when a new version was available. I wrote a small cron job that will mail me from the server. If you want to use it as well, you need to install a few more packages:
sudo pacman -S postfix jq cronie mutt sudo systemctl restart postfix
Then I created the following script:
Simply replace ‘[INSERT EMAIL HERE]’ with your e-mail address. You can then add this to a cron job. My entry looked like:
0 5 * * * /home/jmarsh/bin/unifi.sh
The first run will send you an e-mail because there is no original. Otherwise, you shouldn’t get anything until a new version is out.
Finally, there is the question of making a backup. Because I don’t have a lot of room on my Raspberry Pi 2, I chose not to do a daily backup but instead opted to backup after any major changes to my network. This is how I do it:
sudo systemctl stop unifi sudo tar -czf unifi-controller-backup-2015-01-29.tar.gz /opt/UniFi/data sudo systemctl start unifi