Skip to content

Instantly share code, notes, and snippets.

@cloudnull
Last active January 7, 2024 21:25
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cloudnull/7244539b7481fe23a35d50f7d4b07573 to your computer and use it in GitHub Desktop.
Save cloudnull/7244539b7481fe23a35d50f7d4b07573 to your computer and use it in GitHub Desktop.
Install the latest Unifi Controller on Debian 11
#!/usr/bin/env bash
set -ev
set -o pipefail
# Install dependencies
apt update
apt -y install apt-transport-https ca-certificates wget dirmngr gnupg gnupg2 software-properties-common
# Install old mongo (requried).
wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
# Get compatible java and set it up
mkdir -p /usr/lib/jvm
pushd /usr/lib/jvm
wget 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=246799_424b9da4b48848379167015dcc250d8d' -O java.tgz
tar -xf java.tgz
popd
if ! grep -q java /etc/profile; then
echo "export PATH=\"$(find /usr/lib/jvm/ -type d -name bin | tr '\n' ':')\${PATH}\"" | tee -a /etc/profile
fi
JAVA_HOME=$(find /usr/lib/jvm/ -maxdepth 1 -type d | tail -n 1)
if ! grep -q JAVA_HOME /etc/environment; then
echo export JAVA_HOME=${JAVA_HOME} | tee -a /etc/environment
fi
update-alternatives --remove-all java || true
update-alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 20
# Install unifi
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
# Ensure that the unifi service knows where java 8 is.
if ! grep -q JAVA_HOME /lib/systemd/system/unifi.service; then
mkdir -p /etc/systemd/system/unifi.service.d/
echo -e "[Service]\nEnvironment=JAVA_HOME=${JAVA_HOME}" | sudo tee /etc/systemd/system/unifi.service.d/local.conf
systemctl daemon-reload
fi
apt update
apt -y install unifi
systemctl restart unifi.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment