#!/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=\${PATH}:$(echo $(find /usr/lib/jvm/ -type d -name bin | sed 's/:$/\n/') | tr ' ' ':') | 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 pushd /usr/bin ln -s ${JAVA_HOME}/bin/java popd # 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