Added support for CentOS 8

fix-non-showing-inputs
Mike Hurley 2020-10-01 13:55:16 +00:00
parent 05f29e95a6
commit d5cd1f45e8
1 changed files with 90 additions and 71 deletions

View File

@ -1,62 +1,64 @@
#!/bin/bash
echo "========================================================="
echo "== Shinobi : The Open Source CCTV and NVR Solution =="
echo "========================================================="
echo "This script will install Shinobi CCTV with minimal user"
echo "intervention."
echo
echo "You may skip any components you already have or do not"
echo "wish to install."
echo "========================================================="
read -p "Press [Enter] to begin..."
#Identify version of CentOS
version=$(rpm --eval %{centos_ver})
echo "Installing dependencies and tools"
#Check to see if we are running on a virtual machine
#Set script to use dnf or yum
if [ "$version" = 7 ]; then
pkgmgr="yum"
elif [ "$version" = 8 ]; then
pkgmgr="dnf"
fi
#Check to see if we are running on a virtual machinie
if hostnamectl | grep -oq "Chassis: vm"; then
vm="open-vm-tools"
else
vm=""
fi
#Check to see if we are running CentOS 8
if hostnamectl | grep -oq "Operating System: CentOS Linux 8"; then
os="8"
elif [ hostnamectl | grep -oq "Operating System: CentOS Linux 7" ]; then
os="7"
else
os="7"
fi
if [ "$os" = "7" ]; then
#Installing deltarpm first will greatly increase the download speed of the other packages
sudo yum install deltarpm -y
#Install remaining packages
sudo yum install nano $vm dos2unix net-tools curl wget git make zip -y
#Ensure everything is up to date
echo "Updating system..."
sudo yum update -y
elif [ "$os" = "8" ]; then
#Installing deltarpm first will greatly increase the download speed of the other packages
sudo dnf install drpm -y
#Install remaining packages
sudo dnf install nano $vm dos2unix net-tools curl wget git make zip
#Ensure everything is up to date
fi
#Clear screen
clear
echo "========================================================="
echo "== Shinobi : The Open Source CCTV and NVR Solution =="
echo "========================================================="
echo "This script will install Shinobi CCTV on CentOS $version with"
echo "minimal user intervention."
echo
echo "You may skip any components you already have or do not"
echo "wish to install."
echo "========================================================="
read -p "Press [Enter] to begin..."
#Install dependencies
echo "Installing dependencies and tools"
if [ "$version" = 7 ]; then
#Installing deltarpm first will greatly increase the download speed of the other packages
sudo yum install deltarpm -y -q -e 0
fi
#Install remaining packages
sudo $pkgmgr install $vm nano dos2unix net-tools curl wget git gcc gcc-c++ make zip -y -q -e 0
#Install updates
echo "Updating system"
sudo $pkgmgr update -y -q -e 0
#Skip if running from the Ninja installer
if [ "$1" != 1 ]; then
#Clone git repo and change directory
sudo git clone https://gitlab.com/Shinobi-Systems/Shinobi.git Shinobi
sudo git clone -q https://gitlab.com/Shinobi-Systems/Shinobi.git Shinobi
cd Shinobi
echo "========================================================="
echo "Do you want to use the Master or Development branch of Shinobi?"
read -p "[M]aster or [D]ev " gitbranch
#Changes input to uppercase
gitbranch=${gitbranch^}
if [ "$gitbranch" = "D" ]; then
#Change to dev branch
sudo git checkout dev
@ -67,14 +69,14 @@ fi
if ! [ -x "$(command -v node)" ]; then
echo "========================================================="
echo "Node.js not found, installing..."
sudo curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
sudo yum install nodejs -y
sudo curl --silent --location https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo $pkgmgr install nodejs -y -q -e 0
else
echo "Node.js is already installed..."
echo "Version : $(node -v)"
fi
if ! [ -x "$(command -v npm)" ]; then
sudo yum install npm -y
sudo $pkgmgr install npm -y -q -e 0
fi
echo "========================================================="
@ -85,18 +87,23 @@ ffmpeginstall=${ffmpeginstall^}
if [ "$ffmpeginstall" = "Y" ]; then
#Install EPEL Repo
sudo yum install epel-release -y
#Enable Nux Dextop repo for FFMPEG
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel -y
sudo $pkgmgr install epel-release -y -q -e 0
if [ "$version" = 7 ]; then
#Enable Nux Dextop repo for FFMPEG (CentOS 7)
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel -y -q -e 0
elif [ "$version" = 8 ]; then
#Enable Negativo17 repo for FFMPEG (CentOS 8)
sudo dnf install epel-release dnf-utils -y -q -e 0
sudo yum-config-manager --set-enabled PowerTools
sudo yum-config-manager --add-repo=https://negativo17.org/repos/epel-multimedia.repo
sudo dnf install ffmpeg ffmpeg-devel -y -q -e 0
fi
fi
echo "========================================================="
echo "Do you want to install MariaDB?"
echo
echo "Press [ENTER] for default [MariaDB]"
read -p "[M]ariaDB, or [N]othing " installdbserver
read -p "Do you want to install MariaDB? Y/N " installdbserver
#Changes input to uppercase
sqliteormariadb=${installdbserver^}
@ -107,16 +114,16 @@ if [ "installdbserver" = "M" ] || [ "$installdbserver" = "" ]; then
#Add the MariaDB repository to yum
sudo curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --skip-maxscale
echo "Installing MariaDB..."
sudo yum install mariadb mariadb-server -y
sudo $pkgmgr install mariadb mariadb-server -y -q -e 0
#Start mysql and enable on boot
sudo systemctl start mariadb
sudo systemctl enable mariadb
#Run mysql install
sudo mysql_secure_installation
echo "========================================================="
read -p "Install default database? Y/N " mysqlDefaultData
#Changes input to uppercase
mysqlDefaultData=${mysqlDefaultData^}
@ -126,27 +133,35 @@ if [ "installdbserver" = "M" ] || [ "$installdbserver" = "" ]; then
until [ "$mariadbPasswordConfirmation" = "Y" ]; do
echo "Please enter your MariaDB Password"
read -s sqlpass
echo "Please confirm your MariaDB Password"
read -s sqlpassconfirm
if [ "$sqlpass" == "$sqlpassconfirm" ]; then
mariadbPasswordConfirmation = "Y"
if [ -z "$sqlpass" ] || [ -z "$sqlpassconfirm" ]; then
echo "Password field left blank. To continue without a password"
echo "please type \"confirm\", to enter a pasword press any key"
read nopassconfirmation
if [ "$nopassconfirmation" == "confirm" ]; then
break
fi
elif [ "$sqlpass" == "$sqlpassconfirm" ]; then
mariadbPasswordConfirmation="Y"
else
echo "Passwords did not match."
echo "Please try again."
fi
fi
done
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
fi
elif [ "$installdbserver" = "N" ]; then
echo "========================================================="
echo "Skipping database server installation..."
fi
echo "========================================================="
echo "Installing NPM libraries..."
sudo npm i npm -g
@ -168,7 +183,7 @@ read -p "Automatically create firewall rules? Y/N " createfirewallrules
#Changes input to uppercase
createfirewallrules=${createfirewallrules^}
if [ "$createfirewallrules" = "Y" ]; then
sudo firewall-cmd --permanent --add-port=8080/tcp -q
sudo firewall-cmd --reload -q
@ -177,11 +192,13 @@ fi
#Create default configuration file
if [ ! -e "./conf.json" ]; then
cp conf.sample.json conf.json
echo "Created conf.json"
#Generate a random Cron key for the config file
cronKey=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-30})
cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
#Insert key into conf.json
sed -i -e 's/change_this_to_something_very_random__just_anything_other_than_this/'"$cronKey"'/g' conf.json
echo "Cron key generated"
fi
if [ ! -e "./super.json" ]; then
@ -189,15 +206,15 @@ if [ ! -e "./super.json" ]; then
echo "Enable superuser access?"
echo "This may be useful for account and password managment"
read -p "in commercial deployments. Y/N " createSuperJson
#Changes input to uppercase
createSuperJson=${createSuperJson^}
if [ "$createSuperJson" = "Y" ]; then
if [ "$createSuperJson" = "Y" ]; then
sudo cp super.sample.json super.json
fi
fi
echo "========================================================="
read -p "Start Shinobi on boot? Y/N " startupShinobi
@ -221,18 +238,20 @@ if [ "$startShinobi" = "Y" ]; then
sudo pm2 start cron.js
fi
ipaddress=$(hostname -I)
echo ""
echo "========================================================="
echo "||=============== Installation Complete ===============||"
echo "========================================================="
echo "|| Login with the Superuser and create a new user!! ||"
echo "========================================================="
echo "|| Open http://$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'):8080/super in your browser. ||"
echo "|| Open http://$ipaddress:8080/super in your browser. ||"
echo "========================================================="
if [ "$createSuperJson" = "Y" ]; then
echo "|| Default Superuser : admin@shinobi.video ||"
echo "|| Default Password : admin ||"
echo "|| You can edit these settings in \"super.json\" ||"
echo "|| located in the Shinobi directory. ||"
echo "|| You can edit these settings in \"super.json\" ||"
echo "|| located in the Shinobi directory. ||"
echo "========================================================="
fi