Skip to content

Instantly share code, notes, and snippets.

@phillhocking
Last active December 9, 2019 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillhocking/ba4506f12e6cf9b6522e93132f9c7d91 to your computer and use it in GitHub Desktop.
Save phillhocking/ba4506f12e6cf9b6522e93132f9c7d91 to your computer and use it in GitHub Desktop.
Automating Ubiquiti Unifi installation on 18.04.03
#!/bin/bash
# Check for root and instruct for sudo
if [[ "$EUID" -ne 0 ]]; then
clear
clear
echo "#########################################################################"
echo "#"
echo "# This script needs to be run as root - su or sudo"
echo "#"
echo "#"
echo "#########################################################################"
exit 1
fi
# Back up source list with timestamp
cp /etc/apt/sources.list /etc/apt/sources.list-"$(date "+%F.%T".backup)" || { echo "Could not backup /etc/apt/sources.list" >&2 ; exit 1 ;}
# Update apt source and enable certificate authorities and https transport so apt can connect to the Ubiquiti repository
apt update && apt install ca-certificates apt-transport-https
# Add apt source list for Ubiquiti `unifi` and `mongodb`
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | tee /etc/apt/sources.list.d/100-ubnt-unifi.list
echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
# Install the apt-key for Ubiquiti's Ubuntu repo
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Update apt source to pick up the new repos for unifi and Mongo
apt update
# Install Ubiquiti apt GPG key for the `unifi` repo
wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
# Now that the source lists that have the `unifi` package are in place apt update/upgrade and install
apt update
apt-get upgrade -y
apt install unifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment