From 9a435ac554cbd69a2b8e173c236f37f188850b22 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Sun, 3 Dec 2023 10:59:44 +0000 Subject: [PATCH] Update install.sh --- install.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 4bdea31..ba1e7f9 100644 --- a/install.sh +++ b/install.sh @@ -1,17 +1,85 @@ #!/usr/bin/env bash -if ! which lsb_release >/dev/null -then -sudo apt-get install -y lsb-core > null +# Get username +USER=$(whoami) + +ARCH=$(uname -m) + +# Identify OS +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID + UPSTREAM_ID=${ID_LIKE,,} + + # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' + if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then + UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" + fi + +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE +elif [ -f /etc/debian_version ]; then + # Older Debian, Ubuntu, etc. + OS=Debian + VER=$(cat /etc/debian_version) +elif [ -f /etc/SuSE-release ]; then + # Older SuSE, etc. + OS=SuSE + VER=$(cat /etc/SuSE-release) +elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + OS=RedHat + VER=$(cat /etc/redhat-release) +else + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) fi -sudo apt-get install -y curl sudo > null +# Output debugging info if $DEBUG set +if [ "$DEBUG" = "true" ]; then + echo "OS: $OS" + echo "VER: $VER" + echo "UPSTREAM_ID: $UPSTREAM_ID" + exit 0 +fi + +# Setup prereqs for server +# Common named prereqs +PREREQ="curl sudo gcc g++ make nodejs" +PREREQDEB="dnsutils ufw" +PREREQRPM="bind-utils" +PREREQARCH="bind" + +echo "Installing prerequisites" +if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then + curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get update + sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then + sudo yum update -y + sudo yum install -y ${PREREQ} ${PREREQRPM} # git +elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then + sudo pacman -Syu + sudo pacman -S ${PREREQ} ${PREREQARCH} +else + echo "Unsupported OS" + # Here you could ask the user for permission to try and install anyway + # If they say yes, then do the install + # If they say no, exit the script + exit 1 +fi echo "Installing MeshCentral" -curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - -sudo apt update > null -sudo apt install -y gcc g++ make -sudo apt install -y nodejs sudo npm install -g npm sudo mkdir -p /opt/meshcentral/meshcentral-data