MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.78k stars 496 forks source link

DietPi-Software | Unifi Controller #3708

Closed Gill-Bates closed 2 years ago

Gill-Bates commented 4 years ago

The Unifi Controller is a very popular tool on the Raspberry. I found a guide on the net how to install it:

https://smarthome-training.com/de/unifi-controller-raspberry-pi/

Does anyone have the time and inclination to add the Unifi controller to the software archive so that it can be easily installed via dietpi-software?

PS: Be aware of the missing JAVA_HOME-Bug: https://community.ui.com/questions/Java-Home-Directory-Fail-Issue-on-Ubuntu-RESOLVED/1faea5fd-6eda-4be9-a12f-676ef6be2529

Fireman1224 commented 3 years ago

How can I fix? What do I need to do?

Joulinar commented 3 years ago

Maybe I was not clear enough. You can't install MongoDB on ARM as it is not supported.

Maybe you can use a search engine to find a guide describing a way around.

Fireman1224 commented 3 years ago

OK, no reason to be rude, I know very little about Linux... I guess installing a version other than bullseye? Just trying to figure all this out... There must be a way since I'm running a controller on stretch on a pi 3. simply trying to upgrade... And by the way, I have been using a search engine. I'd much rather do that than ask for help...

Joulinar commented 3 years ago

Well Stretch is quite old and maybe condition changed in meantime. Means, maybe MongoDB was not required before but is it now.

Fireman1224 commented 3 years ago

I'm pretty sure MongoDB has always been required, kinda like Java 8... All the tutorials I've found reference the same install procedures that now don't work... Just trying to understand. Maybe I need Raspian Lite vs dietpi? not sure, just grasping at straws... I really like the performance from dietpi...

Joulinar commented 3 years ago

DietPi is not an own OS, it is a set of shell scripts on top of base image. In case of Raspberry Pi, base image used is Raspberry OS.

If you have a running Stretch system, you should be able to update to Buster as a first step.

Gill-Bates commented 3 years ago

I run it with no issues …

3029D1F5-D71F-428D-B91B-1FF3279E827A

Joulinar commented 3 years ago

I read thru the internet and it seems older version of MongoDB are able to run on Raspberry OS but somewhere in 2000 this changed.

There are a couple of entries on MongoDB support forum requesting support for ARM64. found this as well https://www.mongodb.com/community/forums/t/mongod-4-4-on-rpi4-aarch64-arch-for-unifi/10378

There is another guide on Raspberry forum going same way https://www.raspberrypi.org/forums/viewtopic.php?t=300028

Whatever you do, you need to compile it yourself it seems.

Gill-Bates commented 3 years ago

Maybe this could help? wget http://ftp.br.debian.org/debian/pool/main/o/openjdk-8/openjdk-8-jre-headless_8u252-b09-1~deb9u1_arm64.deb

Joulinar commented 3 years ago

This is a Debian 9 (Stretch) package, something I would not recommend on Buster or Bullseye. To install Java 8 you could use adoptopenjdk repository

https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot#linux-pkg

MichaIng commented 3 years ago

Java 8 is btw still available on Raspbian Bullseye, hence our ARMv6 RPi image, as newer Java versions are not supported on ARMv6. Else AdoptOpenJDK, respectively now named Adoptium is an alternative.

About MongoDB: Isn't is possible to compile it for ARM? EDIT: Ah described in the two links above. An overnight process(on RPi4) with lots of disk I/O and RAM demand, so nothing we can offer as a dietpi-software install option. Better to have this cross-compiled on a capable x86_64 machine, but for ARMv6 creating the environment and build stack is not trivial either...

Joulinar commented 3 years ago

About MongoDB: Isn't is possible to compile it for ARM?

Should be possible according the 2 guides I posted above

Fireman1224 commented 3 years ago

OK, I really appreciate the assistance. I'll see if I can understand the guide.

Thanks!

Joulinar commented 3 years ago

@MichaIng If I'm not mistaken MongoDB reuigeres 64bit on actual version. Means our ARMv6 RPi image isn't a real option. But maybe I'm wrong.

MichaIng commented 3 years ago

As I edited into my post above, just note that you should compile it on an external drive (not an SD card!), have a large swap file in place (also not on an SD card), turn off all other services/software running on that RPi and let it running over night. At best attach an SSD via USB3 for swap file and building, so the disk I/O at least won't be a bottleneck.

I not yet found a definit statement that MongoDB at its core does not support 32-bit, but rather that they stopped to ship 32-bit binaries. Else this would further complicate and limit the abilities to run Unifi Controller, as long as they do not support newer Java versions, as only Raspbian (32-bit) still ships Java 8 natively.

Btw, did someone already try the MongoDB 64-bit ARM Ubuntu package (on our 64-bit image, of course)? https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/5.0/multiverse/binary-arm64/mongodb-org-server_5.0.2_arm64.deb And then Adoptium JRE 8: https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jre_aarch64_linux_hotspot_8u302b08.tar.gz

Gill-Bates commented 3 years ago

@Fireman1224 Try it stupid simple. Don't mess around with compling if you don't have any clue about Linux. It will end up in wasting time and a lot of frustration (but you will learn a lot!) We were all Rookies once. :-)

  1. Run dietpi-software and search in the Software Cataloge for "Docker". Install Docker and if you like Docker-Compose. This may take a while (btw: The Dietpi-Team did a great Job with writing the Setup-Script! 🥇). image

  2. After finishing Installation run the command docker pull linuxserver/unifi-controller. It will load all Dependencies for you. This will also take some time: image

  3. Now, start the Container: docker run -d linuxserver/unifi-controller -p 8443:8443 -p 8080:8080 It will map the Port 8843 from inside the Containers Webserver to your Network.

MichaIng commented 3 years ago

Ah nice, a Docker container exists. Not the implementation we'd add to dietpi-software, but an easy and functional one, until we found an acceptable solution for MongoDB and Java 8.

Fireman1224 commented 3 years ago

@Gill-Bates @MichaIng

So I've never played around with docker, but from what little I have read, it seems like it will be easy enough to try. I had ended up just going back with Raspberry OS and then installing the Unifi Controller on that, but I need a second controller for another location that I have to configure, so I'm going to try the Docker approach. If I can make it work, I may re-do my current site with Docker instead. I appreciate the continued support and advice!!

Question 1: If I set up the USB flash drive on a Pi 4, could I then use it in a Pi 3B+ or do I need to make some adjustments because of the RAM difference?

Question 2: Will I have to run docker run -d linuxserver/unifi-controller -p 8443:8443 -p 8080:8080 each time I reboot the pi or will it automatically start upon reboot after the initial run? Since this is running headless, I would want to have it start automatically.

Question 3: How are the controller version updates handled within Docker?

I apologize for the question bombardment, but this is a new area for me...

Thanks! @

MichaIng commented 3 years ago

A1: No adjustments required, but probably a swap file needs to be created or its size increased when the system on the RPi 4 used it, or used more than 1 GiB physical memory.

A2: The Docker/containerd service itself starts all containers, after having them deployed once.

A3: At least you need to remove the old container, before calling docker run again. Not sure if also the image needs to be removed in every case?

# Remove Docker container
docker rm "$(docker ps -a | mawk '/linuxserver\/unifi-controller/{print $1;exit}')"
# Remove Docker image
docker rmi "$(docker images -a | mawk '/linuxserver\/unifi-controller/{print $3;exit}')"
Joulinar commented 3 years ago

usually the image can be removed as well as a new version will be download. Depending on the Docker application you would need to check if personal data are stored on a location outside the container to ensure not starting from scratch.

MichaIng commented 3 years ago

If settings/data are stored within the Docker image, is removing the container actually sufficient to have it updated, or does this only remove the "image" from being started/controlled by the parent Docker service?

Joulinar commented 3 years ago

Removing the container will have no impact on the image as it will not be updated. Creating a new container will reuse the old image again. That's why dietpi-software is removing container + image on reinstall for our Portainer installation. As well Portainer is configured to use a volume directory outside the container to store all relevant Information.

The image provider (linuxserver/unifi-controller) themselves is using a docker compose file, having a volume path specified. This way data are stored outside the container.

https://hub.docker.com/r/linuxserver/unifi-controller

---
version: "2.1"
services:
  unifi-controller:
    image: ghcr.io/linuxserver/unifi-controller
    container_name: unifi-controller
    environment:
      - PUID=1000
      - PGID=1000
      - MEM_LIMIT=1024M #optional
      - MEM_STARTUP=1024M #optional
    volumes:
      - <path to data>:/config
    ports:
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 8443:8443
      - 1900:1900/udp #optional
      - 8843:8843 #optional
      - 8880:8880 #optional
      - 6789:6789 #optional
      - 5514:5514/udp #optional
    restart: unless-stopped
MichaIng commented 3 years ago

Thanks for clarification. So then the two commands I provided above should do the job, followed by docker run ... of course.

Gill-Bates commented 3 years ago

Running the Docker Container will work on a Rpi 3+, but it’s no joy!

67FDDA6A-5C33-4DC4-8A7D-4A62D0828410

i miss the days, where a simple apt install openjdk-8-jdk-headlessjust worked …

Joulinar commented 3 years ago

Basically JAVA8 should not be the issue as you could install it from AdoptOpenJDK repository https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot#linux-pkg

It's still MongoDB not being available that simple on ARM boards.

Therefore, using Docker container seems to be the easiest solution currently.

Regarding memory consumption, I guess it would be similar without docker. At least on my test, nearly 600MB are used by JAVA 😉 Below a view from my Docker installation for Unifi.

image

BTW: version running inside the container

root@DietPi4:~# docker exec -it unifi-controller java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~18.04-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
root@DietPi4:~# docker exec -it unifi-controller mongod --version
db version v3.6.3
git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
allocator: tcmalloc
modules: none
build environment:
    distarch: aarch64
    target_arch: aarch64
root@DietPi4:~# docker exec -it unifi-controller cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
MichaIng commented 3 years ago

i miss the days, where a simple apt install openjdk-8-jdk-headless just worked …

And this still works with the ARMv6 image.

@Joulinar Don't use AdoptOpenJDK anymore, as it is renamed to Adoptium and they currently build the new infrastructure. So using the old APT repo won't work anymore earlier or later. This is where binaries can be found: https://github.com/adoptium/temurin8-binaries/releases or https://adoptium.net/nightly.html?variant=openjdk8&jvmVariant=hotspot Latest (nightly) arm32 build: https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u-2021-09-02-03-07-beta/OpenJDK8U-jre_arm_linux_hotspot_2021-09-02-03-07.tar.gz

But no APT repository exists yet, so install needs to be done manually:

curl -sSfLO https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u-2021-09-02-03-07-beta/OpenJDK8U-jre_arm_linux_hotspot_2021-09-02-03-07.tar.gz
tar xf OpenJDK8U-jre_arm_linux_hotspot_2021-09-02-03-07.tar.gz -C /opt
ln -s /opt/jdk8u312-b03-jre/bin/java /usr/local/bin/java