Created
February 4, 2025 08:58
-
-
Save cloudnull/f353cacbe6fdda874364fab9f3df4014 to your computer and use it in GitHub Desktop.
Install the latest Unifi Controller on Debian 12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 gnupg curl | |
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ | |
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \ | |
--dearmor | |
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.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