2018-06-09 23:34:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
echo "========================================================="
|
|
|
|
echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!=="
|
|
|
|
echo "========================================================="
|
|
|
|
echo "To answer yes type the letter (y) in lowercase and press ENTER."
|
|
|
|
echo "Default is no (N). Skip any components you already have or don't need."
|
|
|
|
echo "============="
|
2018-10-04 15:24:55 +00:00
|
|
|
#Detect Ubuntu Version
|
|
|
|
echo "============="
|
|
|
|
echo " Detecting Ubuntu Version"
|
|
|
|
echo "============="
|
2018-10-04 22:37:12 +00:00
|
|
|
getubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1)
|
2018-10-04 15:24:55 +00:00
|
|
|
echo "============="
|
|
|
|
echo " Ubuntu Version: $getubuntuversion"
|
|
|
|
echo "============="
|
2018-10-04 22:37:12 +00:00
|
|
|
if [ "$getubuntuversion" = "18" ] || [ "$getubuntuversion" > "18" ]; then
|
2018-10-04 15:24:55 +00:00
|
|
|
apt install sudo wget -y
|
|
|
|
sudo apt install -y software-properties-common
|
|
|
|
sudo add-apt-repository universe -y
|
|
|
|
fi
|
2019-04-03 03:47:03 +00:00
|
|
|
if [ "$getubuntuversion" = "16" ]; then
|
|
|
|
apt install gnupg-curl -y
|
|
|
|
fi
|
2018-10-04 15:24:55 +00:00
|
|
|
#create conf.json
|
2018-06-09 23:34:06 +00:00
|
|
|
if [ ! -e "./conf.json" ]; then
|
|
|
|
sudo cp conf.sample.json conf.json
|
|
|
|
fi
|
2018-10-04 15:24:55 +00:00
|
|
|
#create super.json
|
2018-06-09 23:34:06 +00:00
|
|
|
if [ ! -e "./super.json" ]; then
|
2018-10-05 21:17:30 +00:00
|
|
|
echo "============="
|
2018-11-16 18:50:40 +00:00
|
|
|
echo "Default Superuser : admin@shinobi.video"
|
|
|
|
echo "Default Password : admin"
|
|
|
|
echo "* You can edit these settings in \"super.json\" located in the Shinobi directory."
|
|
|
|
sudo cp super.sample.json super.json
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
2018-12-29 19:32:12 +00:00
|
|
|
if ! [ -x "$(command -v ifconfig)" ]; then
|
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Installing Net-Tools"
|
|
|
|
sudo apt install net-tools -y
|
|
|
|
fi
|
2018-11-16 18:50:40 +00:00
|
|
|
if ! [ -x "$(command -v node)" ]; then
|
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Installing Node.js"
|
2020-01-03 22:58:14 +00:00
|
|
|
wget https://deb.nodesource.com/setup_11.x
|
|
|
|
chmod +x setup_11.x
|
|
|
|
./setup_11.x
|
2018-06-09 23:34:06 +00:00
|
|
|
sudo apt install nodejs -y
|
2020-01-03 22:58:14 +00:00
|
|
|
rm setup_11.x
|
2018-11-16 18:50:40 +00:00
|
|
|
else
|
|
|
|
echo "Node.js Found..."
|
|
|
|
echo "Version : $(node -v)"
|
|
|
|
fi
|
|
|
|
if ! [ -x "$(command -v npm)" ]; then
|
|
|
|
sudo apt install npm -y
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
2019-01-13 21:42:11 +00:00
|
|
|
sudo apt install make zip -y
|
2018-11-16 18:50:40 +00:00
|
|
|
if ! [ -x "$(command -v ffmpeg)" ]; then
|
|
|
|
if [ "$getubuntuversion" = "16" ] || [ "$getubuntuversion" < "16" ]; then
|
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Get FFMPEG 3.x from ppa:jonathonf/ffmpeg-3"
|
|
|
|
sudo add-apt-repository ppa:jonathonf/ffmpeg-3 -y
|
|
|
|
sudo apt update -y && sudo apt install ffmpeg libav-tools x264 x265 -y
|
2018-06-09 23:34:06 +00:00
|
|
|
else
|
2018-11-16 18:50:40 +00:00
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Installing FFMPEG"
|
|
|
|
sudo apt install ffmpeg -y
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
2018-11-16 18:50:40 +00:00
|
|
|
else
|
|
|
|
echo "FFmpeg Found..."
|
|
|
|
echo "Version : $(ffmpeg -version)"
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
|
|
|
echo "============="
|
2019-10-15 18:15:47 +00:00
|
|
|
echo "Shinobi - Do you want to Install MariaDB? Choose No if you already have it."
|
|
|
|
echo "(y)es or (N)o"
|
|
|
|
read mysqlagree
|
|
|
|
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
|
|
|
|
echo "Shinobi - Installing MariaDB"
|
|
|
|
echo "Password for root SQL user, If you are installing SQL now then you may put anything:"
|
|
|
|
read sqlpass
|
|
|
|
echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections
|
|
|
|
echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections
|
|
|
|
sudo apt install mariadb-server -y
|
|
|
|
sudo service mysql start
|
|
|
|
fi
|
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Database Installation"
|
|
|
|
echo "(y)es or (N)o"
|
|
|
|
read mysqlagreeData
|
|
|
|
if [ "$mysqlagreeData" = "y" ] || [ "$mysqlagreeData" = "Y" ]; then
|
2018-06-09 23:34:06 +00:00
|
|
|
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
|
2019-10-15 18:15:47 +00:00
|
|
|
sqluser="root"
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
2019-10-15 18:15:47 +00:00
|
|
|
if [ ! "$mysqlagree" = "y" ]; then
|
|
|
|
echo "What is your SQL Username?"
|
|
|
|
read sqluser
|
|
|
|
echo "What is your SQL Password?"
|
|
|
|
read sqlpass
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
2019-10-15 18:15:47 +00:00
|
|
|
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
|
|
|
|
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
|
2018-06-09 23:34:06 +00:00
|
|
|
fi
|
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Install NPM Libraries"
|
2018-08-11 18:58:15 +00:00
|
|
|
sudo npm i npm -g
|
|
|
|
sudo npm install --unsafe-perm
|
2018-09-23 15:43:29 +00:00
|
|
|
sudo npm audit fix --force
|
2018-06-09 23:34:06 +00:00
|
|
|
echo "============="
|
|
|
|
echo "Shinobi - Install PM2"
|
2019-04-03 03:47:03 +00:00
|
|
|
sudo npm install pm2@3.0.0 -g
|
2018-06-09 23:34:06 +00:00
|
|
|
echo "Shinobi - Finished"
|
|
|
|
sudo chmod -R 755 .
|
|
|
|
touch INSTALL/installed.txt
|
2018-10-04 03:34:50 +00:00
|
|
|
dos2unix /home/Shinobi/INSTALL/shinobi
|
2018-10-03 22:05:29 +00:00
|
|
|
ln -s /home/Shinobi/INSTALL/shinobi /usr/bin/shinobi
|
2018-06-09 23:34:06 +00:00
|
|
|
echo "Shinobi - Start Shinobi and set to start on boot?"
|
|
|
|
echo "(y)es or (N)o"
|
|
|
|
read startShinobi
|
|
|
|
if [ "$startShinobi" = "y" ] || [ "$startShinobi" = "y" ]; then
|
|
|
|
sudo pm2 start camera.js
|
|
|
|
sudo pm2 start cron.js
|
|
|
|
sudo pm2 startup
|
|
|
|
sudo pm2 save
|
|
|
|
sudo pm2 list
|
|
|
|
fi
|
2018-12-29 19:32:12 +00:00
|
|
|
echo "====================================="
|
|
|
|
echo "||===== Install Completed =====||"
|
|
|
|
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 web browser."
|
|
|
|
echo "||==================================="
|
|
|
|
echo "|| Default Superuser : admin@shinobi.video"
|
|
|
|
echo "|| Default Password : admin"
|
|
|
|
echo "====================================="
|
|
|
|
echo "====================================="
|