Skip to content

Instantly share code, notes, and snippets.

@carlos-moreno
Last active March 16, 2024 14:41
Show Gist options
  • Save carlos-moreno/59ce0c09a3863e61809ac1c82547af40 to your computer and use it in GitHub Desktop.
Save carlos-moreno/59ce0c09a3863e61809ac1c82547af40 to your computer and use it in GitHub Desktop.
Install UniFi Network Server on Linux System Debian 10
#!/bin/bash
#------------------------------------------------------------------------------------------
# Script Name: unifi_ns.sh
# Creation Date: 03/16/2024
# Author: Carlos Moreno
# Revision: 0.1.0
# Description: Install UniFi Network Server on Linux System Debian 10.
# Requirement: SO Debian 10.
# Instructions: To run the script, you need to execute the command below.
# chmod +x unifi_ns.sh
# Example of use: bash unifi_ns.sh
# Note: If you are not a superuser, you must use sudo before the call script, as per the command below.
# sudo bash unifi_ns.sh
#------------------------------------------------------------------------------------------
# Update SO
echo "Update the system"
apt update && apt upgrade -y
# Install Java
echo "Install openjdk-17"
apt install -y wget apt-transport-https gnupg
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
apt update && apt install -y temurin-17-jdk
if [[ $? -ne 0 ]]; then
echo "Error: Failed to install Java."
exit 1
fi
# Install MongoDB
echo "Install MongoDB"
apt install -y gnupg curl vim wget
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | gpg -o /usr/share/keyrings/mongodb-server-4.4.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
apt update && apt install -y mongodb-org
if [[ $? -ne 0 ]]; then
echo "Error: Failed to install MongoDB."
exit 1
fi
# Install UniFi
echo "Install UniFi"
apt update && apt install -y ca-certificates apt-transport-https
echo 'deb [arch=amd64,arm64] https://www.ui.com/downloads/unifi/debian stable ubiquiti' | tee /etc/apt/sources.list.d/100-ubnt-unifi.list
wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
apt update && apt install -y unifi
if [[ $? -ne 0 ]]; then
echo "Error: Failed to install UniFi Network Server."
exit 1
fi
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment