Shinobi/INSTALL/opensuse.sh

119 lines
4.3 KiB
Bash
Raw Normal View History

2018-08-27 19:46:27 +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 "============="
if [ ! -e "./conf.json" ]; then
cp conf.sample.json conf.json
fi
if [ ! -e "./super.json" ]; then
echo "Default Superuser : admin@shinobi.video"
echo "Default Password : admin"
sudo cp super.sample.json super.json
echo "Shinobi - Do you want to enable superuser access?"
echo "This may be useful if passwords are forgotten or"
echo "if you would like to limit accessibility of an"
echo "account for business scenarios."
echo "(y)es or (N)o"
read -r createSuperJson
2018-08-27 19:46:27 +00:00
if [ "$createSuperJson" = "y" ] || [ "$createSuperJson" = "Y" ]; then
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
fi
fi
2018-08-27 20:10:21 +00:00
echo "Shinobi - Run zypper refresh"
2018-08-27 19:46:27 +00:00
sudo zypper refresh
sudo zypper install -y make
echo "============="
2018-08-27 20:02:02 +00:00
echo "Shinobi - Do you want to Install Node.js?"
echo "(y)es or (N)o"
NODEJSINSTALL=0
read -r nodejsinstall
2018-08-27 20:02:02 +00:00
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
2020-01-03 22:58:14 +00:00
sudo zypper install -y nodejs11
2018-08-27 20:02:02 +00:00
NODEJSINSTALL=1
fi
echo "============="
2018-08-27 19:46:27 +00:00
echo "Shinobi - Do you want to Install FFMPEG?"
echo "(y)es or (N)o"
read -r ffmpeginstall
2018-08-27 19:46:27 +00:00
if [ "$ffmpeginstall" = "y" ] || [ "$ffmpeginstall" = "Y" ]; then
2018-08-27 20:02:02 +00:00
# Without nodejs8 package we can't use npm command
if [ "$NODEJSINSTALL" -eq "1" ]; then
2018-10-10 20:40:23 +00:00
echo "Shinobi - Do you want to Install FFMPEG with 'zypper --version' or download a static version provided with npm 'npm --version'?"
2018-08-27 20:02:02 +00:00
echo "(z)ypper or (N)pm"
echo "Press [ENTER] for default (npm)"
read -r ffmpegstaticinstall
2018-08-27 20:02:02 +00:00
if [ "$ffmpegstaticinstall" = "z" ] || [ "$ffmpegstaticinstall" = "Z" ]; then
# Install ffmpeg and ffmpeg-devel
sudo zypper install -y ffmpeg ffmpeg-devel
else
sudo npm install ffbinaries
2018-08-27 20:02:02 +00:00
fi
2018-08-27 19:46:27 +00:00
else
2018-08-27 20:02:02 +00:00
sudo zypper install -y ffmpeg ffmpeg-devel
2018-08-27 19:46:27 +00:00
fi
fi
echo "============="
echo "Shinobi - Do you want to Install MariaDB?"
echo "(y)es or (N)o"
read -r mysqlagree
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
sudo zypper install -y mariadb
#Start mysql and enable on boot
sudo systemctl start mariadb
sudo systemctl enable mariadb
#Run mysql install
sudo mysql_secure_installation
fi
echo "============="
echo "Shinobi - Database Installation"
echo "(y)es or (N)o"
read -r mysqlagreeData
if [ "$mysqlagreeData" = "y" ] || [ "$mysqlagreeData" = "Y" ]; then
echo "What is your SQL Username?"
read -r sqluser
echo "What is your SQL Password?"
read -r sqlpass
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-08-27 19:46:27 +00:00
fi
echo "============="
echo "Shinobi - Install NPM Libraries"
2018-09-23 15:43:29 +00:00
npm i npm -g
npm install --unsafe-perm
sudo npm audit fix --force
2018-08-27 19:46:27 +00:00
echo "============="
echo "Shinobi - Install PM2"
sudo npm install pm2@3.0.0 -g
2018-08-27 19:46:27 +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-08-27 19:46:27 +00:00
echo "Shinobi - Start Shinobi and set to start on boot?"
echo "(y)es or (N)o"
read -r startShinobi
2018-08-27 19:46:27 +00:00
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
echo "====================================="
echo "||===== Install Completed =====||"
echo "====================================="
echo "|| Login with the Superuser and create a new user!!"
echo "||==================================="
echo "|| Open http://$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1):8080/super in your web browser."
echo "||==================================="
echo "|| Default Superuser : admin@shinobi.video"
echo "|| Default Password : admin"
echo "====================================="
echo "====================================="