mirror of
https://github.com/techahold/Meshcentral-Installer.git
synced 2026-05-21 14:02:15 +00:00
Update install.sh
This commit is contained in:
99
install.sh
99
install.sh
@@ -3,8 +3,13 @@
|
|||||||
# Get username
|
# Get username
|
||||||
USER=$(whoami)
|
USER=$(whoami)
|
||||||
|
|
||||||
|
#Get Architecture
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
# Set Node Version
|
||||||
|
NODE_MAJOR=20
|
||||||
|
|
||||||
|
|
||||||
# Identify OS
|
# Identify OS
|
||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
# freedesktop.org and systemd
|
# freedesktop.org and systemd
|
||||||
@@ -55,19 +60,24 @@ fi
|
|||||||
|
|
||||||
# Setup prereqs for server
|
# Setup prereqs for server
|
||||||
# Common named prereqs
|
# Common named prereqs
|
||||||
PREREQ="curl sudo gcc g++ make nodejs"
|
PREREQ="curl sudo gcc g++ make"
|
||||||
PREREQDEB="dnsutils ufw"
|
PREREQDEB="nodejs"
|
||||||
PREREQRPM="bind-utils"
|
PREREQARCH="nodejs-lts-iron"
|
||||||
PREREQARCH="bind"
|
|
||||||
|
|
||||||
echo "Installing prerequisites"
|
echo "Installing prerequisites"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
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 update
|
||||||
sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git
|
sudo apt-get install -y ca-certificates curl gnupg
|
||||||
|
sudo mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y ${PREREQ} ${PREREQDEB}
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then
|
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then
|
||||||
|
sudo yum install https://rpm.nodesource.com/pub_$NODE_MAJOR.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y --nogpgcheck
|
||||||
|
sudo yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1 --nogpgcheck
|
||||||
sudo yum update -y
|
sudo yum update -y
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
sudo yum install -y ${PREREQ}
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
sudo pacman -Syu
|
sudo pacman -Syu
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
||||||
@@ -140,61 +150,13 @@ echo "You will now be given a choice of what database you want to use"
|
|||||||
|
|
||||||
# Choice for Database
|
# Choice for Database
|
||||||
PS3='Choose your preferred option for database server:'
|
PS3='Choose your preferred option for database server:'
|
||||||
DB=("NeDB" "MongoDB" "Postgres")
|
DB=("NeDB" "Postgres")
|
||||||
select DBOPT in "${DB[@]}"; do
|
select DBOPT in "${DB[@]}"; do
|
||||||
case $DBOPT in
|
case $DBOPT in
|
||||||
"NeDB")
|
"NeDB")
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"MongoDB")
|
|
||||||
while ! [[ $CHECK_MESH_SERVICE1 ]]; do
|
|
||||||
CHECK_MESH_SERVICE1=$(sudo systemctl status meshcentral.service | grep "Active: active (running)")
|
|
||||||
echo -ne "Meshcentral not ready yet...${NC}\n"
|
|
||||||
sleep 3
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo systemctl stop meshcentral
|
|
||||||
|
|
||||||
echo "Installing Mongodb"
|
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
|
||||||
if [ $(lsb_release -si | tr '[:upper:]' '[:lower:]') = "ubuntu" ]
|
|
||||||
then
|
|
||||||
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
|
||||||
echo "deb http://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/5.0" multiverse | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
|
||||||
elif [ $(lsb_release -si | tr '[:upper:]' '[:lower:]') = "debian" ]
|
|
||||||
then
|
|
||||||
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
|
||||||
echo "deb http://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/5.0" main | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo apt-get update > null
|
|
||||||
sudo apt-get install -y mongodb-org > null
|
|
||||||
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"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo systemctl enable mongod
|
|
||||||
sudo systemctl start mongod
|
|
||||||
sed -i '/"settings": {/a "MongoDb": "mongodb://127.0.0.1:27017/meshcentral",\n"MongoDbCol": "meshcentral",' /opt/meshcentral/meshcentral-data/config.json
|
|
||||||
|
|
||||||
while ! [[ $CHECK_MONGO_SERVICE ]]; do
|
|
||||||
CHECK_MONGO_SERVICE=$(sudo systemctl status mongod.service | grep "Active: active (running)")
|
|
||||||
echo -ne "MongoDB is not ready yet...${NC}\n"
|
|
||||||
sleep 3
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo systemctl start meshcentral.service
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
|
|
||||||
"Postgres")
|
"Postgres")
|
||||||
while ! [[ $CHECK_MESH_SERVICE2 ]]; do
|
while ! [[ $CHECK_MESH_SERVICE2 ]]; do
|
||||||
CHECK_MESH_SERVICE2=$(sudo systemctl status meshcentral.service | grep "Active: active (running)")
|
CHECK_MESH_SERVICE2=$(sudo systemctl status meshcentral.service | grep "Active: active (running)")
|
||||||
@@ -206,14 +168,11 @@ sudo systemctl stop meshcentral
|
|||||||
|
|
||||||
echo "Installing Postgresql"
|
echo "Installing Postgresql"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
sudo apt-get install -y postgresql > null
|
sudo apt-get install -y postgresql > null
|
||||||
|
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then
|
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 postgresql
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
sudo pacman -Syu
|
sudo pacman -S postgresql
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
|
||||||
else
|
else
|
||||||
echo "Unsupported OS"
|
echo "Unsupported OS"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -242,13 +201,10 @@ then
|
|||||||
echo "Installing Postgresql dependencies"
|
echo "Installing Postgresql dependencies"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
sudo apt-get install -y jq > null
|
sudo apt-get install -y jq > null
|
||||||
|
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then
|
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 jq
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
sudo pacman -Syu
|
sudo pacman -S jq
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
|
||||||
else
|
else
|
||||||
echo "Unsupported OS"
|
echo "Unsupported OS"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -284,14 +240,11 @@ if ! which jq >/dev/null
|
|||||||
then
|
then
|
||||||
echo "Installing further dependencies"
|
echo "Installing further dependencies"
|
||||||
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
|
||||||
sudo apt-get install -y jq > null
|
sudo apt-get install -y jq > null
|
||||||
|
|
||||||
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "${OS}" = "Almalinux" ] || [ "${UPSTREAM_ID}" = "Rocky*" ] || [ "${UPSTREAM_ID}" = "suse" ]; then
|
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 jq
|
||||||
sudo yum install -y ${PREREQ} ${PREREQRPM} # git
|
|
||||||
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
elif [ "${ID}" = "arch" ] || [ "${UPSTREAM_ID}" = "arch" ]; then
|
||||||
sudo pacman -Syu
|
sudo pacman -S jq
|
||||||
sudo pacman -S ${PREREQ} ${PREREQARCH}
|
|
||||||
else
|
else
|
||||||
echo "Unsupported OS"
|
echo "Unsupported OS"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user