Skip to content

Instantly share code, notes, and snippets.

@codeniko
Last active June 22, 2023 02:23
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save codeniko/381e8be3b0236a602e02f0a9fac13b3d to your computer and use it in GitHub Desktop.
Save codeniko/381e8be3b0236a602e02f0a9fac13b3d to your computer and use it in GitHub Desktop.
Setup UNMS and Unifi network controller on Raspberry pi 4 Raspbian buster

Setup Raspbian Buster

I'm using debian 10 as my daily so these are *nix commands. Mac should work with these too but you're on your own if you're using Windows. Goal for me is to make a headless raspberry pi I can SSH into and connect to my network using Ethernet. You should be comfortable in command line if you choose to follow this guide.

  1. Go to https://www.raspberrypi.org/downloads/raspbian and download Raspbian lite archive
  2. unzip the image
  3. Plug in sdcard. Run lsblk to see drives and mount points. Likely, the sdcard will show up in /dev/sda or /dev/sdb and may have some partitions like /dev/sda1 and /dev/sda2.
  4. If partitions are mounted, unmount all of them. Ex: umount /dev/sda1 and umount /dev/sda2
  5. Copy the raspbian image to the sdcard with sudo dd if=RASPBIAN_IMAGE_FILE.img of=/dev/sda bs=4M
  6. Run sync to ensure the written contents are flushed
  7. OPTIONAL: To start ssh server on boot, Unplug sdcard and reinsert to remount new partitions. You'll have two with raspbian. Add ssh empty file with touch /media/NAME_OF_DRIVE/boot/ssh . Run sync again to flush and then unmount.
  8. Stick the sdcard into your raspberry pi and turn it on. It should start and the SSH server should start with it if you did step 7.
  9. Find Pi's assigned local IP from your router and finally ssh in with ssh pi@LOCAL_ADDRESS. Password is "raspberry"

Setup Unifi network controller and UNMS

The following is to be run on the Pi itself after SSHing in.

Setup Unifi network controller

First we need java 8 because Unifi is so out of date. After hours of trying to figure out how to get it because Java 8 has been discontinued and no longer publically accessible, I did finally discover a way to get it.

sudo apt-get update
sudo apt-get install openjdk-8-jre-headless

Verify java 8 installed with java -version

Now to actually install unifi controller. There are two unifi official guides on this. One is to use apt repository which won't work because Unifi doesn't support armhf, and the other is to install the package yourself. We need to do the latter to make it work. You can find those instructions at the following link, however STOP BEFORE STEP 8 and follow my directions instead as it's slightly different: https://help.ubnt.com/hc/en-us/articles/360012282453-UniFi-How-to-Install-Upgrade-the-UniFi-Network-Controller-Software Instead of step 8, do sudo apt-get install ./unifi_sysvinit_all.deb as this will install all dependencies like the correct mongodb packages and others. It should succeed without errors and the controller should be accessible from https://PI_LOCAL_HOST:8443

Setup UNMS

UNMS won't work without us setting up docker. To do this, we'll be setting up oznu/docker-unms image. However, their wiki page doesn't work for Debian buster, only stretch. Do NOT follow the directions on https://github.com/oznu/docker-unms/wiki/UNMS-on-Raspberry-Pi as the first few steps won't work. Docker recommends to use convenience scripts to install itself on Raspbian, including Raspbian buster. Follow https://docs.docker.com/install/linux/docker-ce/debian/#install-using-the-convenience-script .

Don't forget to add the docker group to the pi user by running sudo usermod -aG docker pi. Close the SSH connection and ssh in again to get the usergroup updated in the new session. Finally test docker to ensure it's working with docker run hello-world

Now we need to install docker-compose.

# Install python and tools
sudo apt-get -y install python-setuptools

# Install pip
sudo python /usr/lib/python2.7/dist-packages/easy_install.py pip

# Use pip to install docker-compose
sudo pip install docker-compose~=1.23.0

With docker-compose installed, from here you can follow Steps 3 and 4 in the following link to setup the docker compose manifest and to start the server: https://github.com/oznu/docker-unms/wiki/UNMS-on-Raspberry-Pi#3-create-docker-compose-manifest . You're done and can access UNMS at https://PI_LOCAL_HOST

@da9l
Copy link

da9l commented Dec 30, 2020

Would it make sense or even be possible to run unifi containerized as well?
Found this image for instance: https://hub.docker.com/r/jacobalberty/unifi

@david-staas
Copy link

david-staas commented Jan 1, 2021

Thank you for this! I only ran into one problem during the last step (docker-compose up -d) and I was able to fix it via:

sudo pip uninstall backports.ssl-match-hostname
sudo apt-get install python-backports.ssl-match-hostname

@codeniko
Copy link
Author

codeniko commented Jan 4, 2021

Would it make sense or even be possible to run unifi containerized as well?
Found this image for instance: https://hub.docker.com/r/jacobalberty/unifi

Certainly, I dont see why a container wont work. If I could rewind time, I'd attempt a containered unifi first. I wasn't too familiar with docker at the time I installed Unifi and only started exploring it since UNMS wasn't working for me otherwise. If you give it a shot and document your experience, I'll gladly link to it for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment