Skip to content

Instantly share code, notes, and snippets.

@chrisloweau
Last active June 12, 2018 15:44
Show Gist options
  • Save chrisloweau/0d6afede148fd7994e47379204dcc476 to your computer and use it in GitHub Desktop.
Save chrisloweau/0d6afede148fd7994e47379204dcc476 to your computer and use it in GitHub Desktop.
UniFi 5 Installation Script for Ubuntu
#!/bin/bash
################################################################################
#
# This script automates the installation of the UniFi controller software on
# Ubuntu.
#
# http://www.technologist.site/ubnt
#
################################################################################
apt update && apt -y upgrade
#
# SOURCES
#
# Oracle Java 8
add-apt-repository -y ppa:webupd8team/java
# MongoDB 3.6
echo 'deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse' > /etc/apt/sources.list.d/mongodb-org-3.6.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
# UniFi 5
echo 'deb https://www.ubnt.com/downloads/unifi/debian stable ubiquiti' > /etc/apt/sources.list.d/100-ubnt.list
wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ubnt.com/unifi/unifi-repo.gpg
apt update
#
# INSTALL
#
# Oracle Java 8
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
apt install -y oracle-java8-installer
# MongoDB 3.6
apt install -y mongodb-org
# UniFi legacy parameter "workaround" for MongoDB 3.x
mv /usr/bin/mongod /usr/bin/mongod.bin
echo '#!/bin/bash' > /usr/bin/mongod
echo 'cleaned_args=$(echo $* | sed -e '\''s/--nohttpinterface//'\'')' >> /usr/bin/mongod
echo 'exec /usr/bin/mongod.bin ${cleaned_args}' >> /usr/bin/mongod
chmod +x /usr/bin/mongod
# UniFi 5
apt install -y unifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment