mirror of
https://gitlab.com/Shinobi-Systems/ShinobiCE.git
synced 2025-03-09 15:40:15 +00:00
Shinobi CE officially lands on Gitlab
This commit is contained in:
commit
f1406d4eec
431 changed files with 118157 additions and 0 deletions
1
INSTALL/.gitignore
vendored
Normal file
1
INSTALL/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
installed.txt
|
17
INSTALL/README.md
Normal file
17
INSTALL/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
#### Fast Install (The Ninja Way)
|
||||
|
||||
1. Become `root` to use the installer and run Shinobi. Use one of the following to do so.
|
||||
|
||||
- Ubuntu 17.04, 17.10
|
||||
- `sudo su`
|
||||
- CentOS 7
|
||||
- `su`
|
||||
- MacOS 10.7(+)
|
||||
- `su`
|
||||
2. Download and run the installer.
|
||||
|
||||
```
|
||||
bash <(curl -s https://raw.githubusercontent.com/ShinobiCCTV/Shinobi-Installer/master/shinobi-install.sh)
|
||||
```
|
||||
|
||||
More info can be found here. https://shinobi.video/docs/start
|
5
INSTALL/autoinstall-ubuntu-latest.sh
Normal file
5
INSTALL/autoinstall-ubuntu-latest.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
apt install git -y
|
||||
git clone https://github.com/ShinobiCCTV/Shinobi.git -b dev Shinobi-dev
|
||||
cd Shinobi-dev
|
||||
chmod +x INSTALL/ubuntu-easyinstall.sh && INSTALL/ubuntu-easyinstall.sh
|
||||
bash INSTALL/ubuntu-easyinstall.sh
|
5
INSTALL/autoinstall-ubuntu-stable.sh
Normal file
5
INSTALL/autoinstall-ubuntu-stable.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
apt install git -y
|
||||
git clone https://github.com/ShinobiCCTV/Shinobi.git Shinobi
|
||||
cd Shinobi
|
||||
chmod +x INSTALL/ubuntu-easyinstall.sh && INSTALL/ubuntu-easyinstall.sh
|
||||
bash INSTALL/ubuntu-easyinstall.sh
|
188
INSTALL/centos.sh
Normal file
188
INSTALL/centos.sh
Normal file
|
@ -0,0 +1,188 @@
|
|||
#!/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 createSuperJson
|
||||
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
|
||||
echo "Shinobi - Run yum update"
|
||||
sudo yum update -y
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install FFMPEG?"
|
||||
echo "(y)es or (N)o"
|
||||
read ffmpeginstall
|
||||
if [ "$ffmpeginstall" = "y" ] || [ "$ffmpeginstall" = "Y" ]; then
|
||||
echo "Shinobi - Do you want to Install FFMPEG with `apt` or download a static version provided with `npm`?"
|
||||
echo "(a)pt or (N)pm"
|
||||
echo "Press [ENTER] for default (npm)"
|
||||
read ffmpegstaticinstall
|
||||
if [ "$ffmpegstaticinstall" = "a" ] || [ "$ffmpegstaticinstall" = "A" ]; 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
|
||||
else
|
||||
sudo npm install ffmpeg-static
|
||||
fi
|
||||
fi
|
||||
echo "Shinobi - Do you want to Install Node.js?"
|
||||
echo "(y)es or (N)o"
|
||||
read nodejsinstall
|
||||
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
|
||||
sudo wget https://rpm.nodesource.com/setup_8.x
|
||||
sudo chmod +x setup_8.x
|
||||
./setup_8.x
|
||||
sudo yum install nodejs -y
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to use MariaDB or SQLite3?"
|
||||
echo "SQLite3 is better for small installs"
|
||||
echo "MariaDB (MySQL) is better for large installs"
|
||||
echo "(S)QLite3 or (M)ariaDB?"
|
||||
echo "Press [ENTER] for default (MariaDB)"
|
||||
read sqliteormariadb
|
||||
if [ "$sqliteormariadb" = "S" ] || [ "$sqliteormariadb" = "s" ]; then
|
||||
sudo npm install jsonfile
|
||||
sudo yum install -y sqlite sqlite-devel -y
|
||||
sudo npm install sqlite3
|
||||
node ./tools/modifyConfiguration.js databaseType=sqlite3
|
||||
if [ ! -e "./shinobi.sqlite" ]; then
|
||||
echo "Creating shinobi.sqlite for SQLite3..."
|
||||
sudo cp sql/shinobi.sample.sqlite shinobi.sqlite
|
||||
else
|
||||
echo "shinobi.sqlite already exists. Continuing..."
|
||||
fi
|
||||
else
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install MariaDB?"
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagree
|
||||
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
|
||||
sudo yum install mariadb mariadb-server -y
|
||||
#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 mysqlagreeData
|
||||
if [ "$mysqlagreeData" = "y" ] || [ "$mysqlagreeData" = "Y" ]; then
|
||||
echo "What is your SQL Username?"
|
||||
read sqluser
|
||||
echo "What is your SQL Password?"
|
||||
read 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
|
||||
echo "Shinobi - Do you want to create a new user for viewing and managing cameras in Shinobi? You can do this later in the Superuser panel."
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlDefaultData
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
escapeReplaceQuote='\\"'
|
||||
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
|
||||
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
|
||||
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
|
||||
userDetails='{"days":"10"}'
|
||||
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
echo $userDetailsNew
|
||||
apiIP='0.0.0.0'
|
||||
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
|
||||
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
rm sql/default_user.sql || true
|
||||
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
|
||||
sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
|
||||
echo "The following details will be shown again at the end of the installation."
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Install NPM Libraries"
|
||||
sudo npm install
|
||||
echo "============="
|
||||
echo "Shinobi - Install PM2"
|
||||
sudo npm install pm2 -g
|
||||
echo "Shinobi - Finished"
|
||||
sudo chmod -R 755 .
|
||||
touch INSTALL/installed.txt
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
echo "=====================================" > INSTALL/installed.txt
|
||||
echo "======= Login Credentials =======" >> INSTALL/installed.txt
|
||||
echo "|| Username : $userEmail" >> INSTALL/installed.txt
|
||||
echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt
|
||||
echo "|| API Key : $apiKey" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
fi
|
||||
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
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
echo "details written to INSTALL/installed.txt"
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
fi
|
||||
if [ ! "$sqliteormariadb" = "M" ] && [ ! "$sqliteormariadb" = "m" ]; then
|
||||
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 "====================================="
|
||||
else
|
||||
echo "+=================================+"
|
||||
echo "||===== Install Completed =====||"
|
||||
echo "|| Access the main Shinobi panel at http://$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'):8080 in your web browser."
|
||||
echo "+=================================+"
|
||||
fi
|
15
INSTALL/cuda4-part1.sh
Normal file
15
INSTALL/cuda4-part1.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
#https://devtalk.nvidia.com/default/topic/1000340/cuda-setup-and-installation/-quot-nvidia-smi-has-failed-because-it-couldn-t-communicate-with-the-nvidia-driver-quot-ubuntu-16-04/4
|
||||
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
|
||||
sudo echo "# NVIDIA Graphics Driver Repo (Added by Shinobi installer)" | sudo tee -a /etc/apt/sources.list
|
||||
sudo echo "# Public Key : sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub" | sudo tee -a /etc/apt/sources.list
|
||||
sudo echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" | sudo tee -a /etc/apt/sources.list
|
||||
apt update
|
||||
sudo apt -y install nvidia-340 nvidia-340-dev nvidia-modprobe libcuda1-340 libcuda1-340-updates nvidia-prime
|
||||
|
||||
echo "After rebooting you need to run part 2. The file is named `cuda9-part2-after-reboot.sh`."
|
||||
echo "Reboot is required. Do it now?"
|
||||
echo "(y)es or (N)o"
|
||||
read rebootTheMachineHomie
|
||||
if [ "$rebootTheMachineHomie" = "y" ] || [ "$rebootTheMachineHomie" = "Y" ]; then
|
||||
sudo reboot
|
||||
fi
|
15
INSTALL/cuda9-part1.sh
Normal file
15
INSTALL/cuda9-part1.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
#https://devtalk.nvidia.com/default/topic/1000340/cuda-setup-and-installation/-quot-nvidia-smi-has-failed-because-it-couldn-t-communicate-with-the-nvidia-driver-quot-ubuntu-16-04/4
|
||||
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
|
||||
sudo echo "# NVIDIA Graphics Driver Repo (Added by Shinobi installer)" | sudo tee -a /etc/apt/sources.list
|
||||
sudo echo "# Public Key : sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub" | sudo tee -a /etc/apt/sources.list
|
||||
sudo echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" | sudo tee -a /etc/apt/sources.list
|
||||
apt update
|
||||
sudo apt -y install cuda-drivers
|
||||
|
||||
echo "After rebooting you need to run part 2. The file is named `cuda9-part2-after-reboot.sh`."
|
||||
echo "Reboot is required. Do it now?"
|
||||
echo "(y)es or (N)o"
|
||||
read rebootTheMachineHomie
|
||||
if [ "$rebootTheMachineHomie" = "y" ] || [ "$rebootTheMachineHomie" = "Y" ]; then
|
||||
sudo reboot
|
||||
fi
|
2
INSTALL/cuda9-part2-after-reboot.sh
Normal file
2
INSTALL/cuda9-part2-after-reboot.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
sudo apt-get -y install cuda-toolkit-9-1
|
||||
nvidia-smi
|
22
INSTALL/ffmpeg.sh
Normal file
22
INSTALL/ffmpeg.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
echo "============="
|
||||
echo "Install FFMPEG"
|
||||
echo "What build of FFMPEG do you require?"
|
||||
echo "If you don't know check your CPU specs for a hint."
|
||||
echo "- 32bit"
|
||||
echo "- 64bit"
|
||||
echo "- armel-32bit"
|
||||
echo "- armhf-32bit"
|
||||
read ffmpegbuild
|
||||
wget "https://s3.amazonaws.com/cloudcamio/ffmpeg-release-$ffmpegbuild-static.tar.xz"
|
||||
tar xf "ffmpeg-release-$ffmpegbuild-static.tar.xz"
|
||||
mv "ffmpeg-3.3-$ffmpegbuild-static/ffmpeg" "/usr/bin/ffmpeg"
|
||||
mv "ffmpeg-3.3-$ffmpegbuild-static/ffmpeg-10bit" "/usr/bin/ffmpeg-10bit"
|
||||
mv "ffmpeg-3.3-$ffmpegbuild-static/ffprobe" "/usr/bin/ffprobe"
|
||||
mv "ffmpeg-3.3-$ffmpegbuild-static/ffserver" "/usr/bin/ffserver"
|
||||
chmod +x /usr/bin/ffmpeg
|
||||
chmod +x /usr/bin/ffmpeg-10bit
|
||||
chmod +x /usr/bin/ffprobe
|
||||
chmod +x /usr/bin/ffserver
|
||||
rm -rf "ffmpeg-3.3-$ffmpegbuild-static"
|
||||
rm -rf "ffmpeg-release-$ffmpegbuild-static.tar.xz"
|
73
INSTALL/freebsd.sh
Normal file
73
INSTALL/freebsd.sh
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/tcsh
|
||||
echo "========================================================="
|
||||
echo "==== Shinobi : The Open Source CCTV and NVR Solution ===="
|
||||
echo "========================================================="
|
||||
echo "This script should run as root inside your jail from the root"
|
||||
echo "of the cloned git repository."
|
||||
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 "============="
|
||||
echo "Shinobi - Do you want to Install Node.js?"
|
||||
echo "(y)es or (N)o"
|
||||
set nodejsinstall = $<
|
||||
if ( $nodejsinstall == "y" ) then
|
||||
pkg install -y node npm
|
||||
endif
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install FFMPEG?"
|
||||
echo "(y)es or (N)o"
|
||||
set ffmpeginstall = $<
|
||||
if ( $ffmpeginstall == "y" ) then
|
||||
pkg install -y ffmpeg libav x264 x265
|
||||
endif
|
||||
echo "============="
|
||||
echo "Shinobi - Database Installation"
|
||||
echo "WARNING - This requires an existing and running mariadb service."
|
||||
echo "(y)es or (N)o"
|
||||
set mysqlagreeData = $<
|
||||
if ( $mysqlagreeData == "y" ) then
|
||||
echo "What is your SQL Username?"
|
||||
set sqluser = $<
|
||||
echo "What is your SQL Password?"
|
||||
set sqlpass = $<
|
||||
echo "What is your SQL Host?"
|
||||
set sqlhost = $<
|
||||
echo "Installing mariadb client..."
|
||||
pkg install -y mariadb102-client
|
||||
echo "Installing database schema..."
|
||||
mysql -h $sqlhost -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
|
||||
mysql -h $sqlhost -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
|
||||
echo "Shinobi - Use the /super endpoint to create your super user."
|
||||
endif
|
||||
echo "============="
|
||||
echo "Shinobi - Install NPM Libraries"
|
||||
npm install
|
||||
echo "============="
|
||||
echo "Shinobi - Install PM2"
|
||||
npm install pm2 -g
|
||||
if (! -e "./conf.json" ) then
|
||||
cp conf.sample.json conf.json
|
||||
endif
|
||||
if (! -e "./super.json" ) then
|
||||
echo "Default Superuser : admin@shinobi.video"
|
||||
echo "Default Password : admin"
|
||||
cp super.sample.json super.json
|
||||
endif
|
||||
echo "Shinobi - Start Shinobi?"
|
||||
echo "(y)es or (N)o"
|
||||
set startShinobi = $<
|
||||
if ( $startShinobi == "y" ) then
|
||||
set PM2BIN="$PWD/node_modules/pm2/bin"
|
||||
$PM2BIN/pm2 start camera.js
|
||||
$PM2BIN/pm2 start cron.js
|
||||
$PM2BIN/pm2 save
|
||||
$PM2BIN/pm2 list
|
||||
endif
|
||||
echo "Shinobi - Start on boot?"
|
||||
echo "(y)es or (N)o"
|
||||
set startupShinobi = $<
|
||||
if ( $startupShinobi == "y" ) then
|
||||
set PM2BIN="$PWD/node_modules/pm2/bin"
|
||||
$PM2BIN/pm2 startup rcd
|
||||
endif
|
||||
echo "Shinobi - Finished"
|
37
INSTALL/installDatabase.js
Normal file
37
INSTALL/installDatabase.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
var knex = require('knex');
|
||||
if(config.databaseType===undefined){config.databaseType='mysql'}
|
||||
|
||||
var databaseOptions = {
|
||||
client: config.databaseType,
|
||||
connection: config.db,
|
||||
}
|
||||
if(databaseOptions.client.indexOf('sqlite')>-1){
|
||||
databaseOptions.client = 'sqlite3';
|
||||
databaseOptions.useNullAsDefault = true;
|
||||
}
|
||||
if(databaseOptions.client === 'sqlite3' && databaseOptions.connection.filename === undefined){
|
||||
databaseOptions.connection.filename = __dirname+"/shinobi.sqlite"
|
||||
}
|
||||
s.databaseEngine = knex(databaseOptions)
|
||||
s.sqlQuery = function(query,values,onMoveOn,hideLog){
|
||||
if(!values){values=[]}
|
||||
if(typeof values === 'function'){
|
||||
var onMoveOn = values;
|
||||
var values = [];
|
||||
}
|
||||
if(!onMoveOn){onMoveOn=function(){}}
|
||||
return s.databaseEngine.raw(query,values)
|
||||
.asCallback(function(err,r){
|
||||
if(err&&config.databaseLogs){
|
||||
s.systemLog('s.sqlQuery QUERY',query)
|
||||
s.systemLog('s.sqlQuery ERROR',err)
|
||||
}
|
||||
if(onMoveOn)
|
||||
if(typeof onMoveOn === 'function'){
|
||||
if(!r)r=[]
|
||||
onMoveOn(err,r)
|
||||
}else{
|
||||
console.log(onMoveOn)
|
||||
}
|
||||
})
|
||||
}
|
90
INSTALL/macos-part2.sh
Normal file
90
INSTALL/macos-part2.sh
Normal file
|
@ -0,0 +1,90 @@
|
|||
|
||||
#!/bin/bash
|
||||
echo "========================================================="
|
||||
echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!=="
|
||||
echo "=================== Mac OS Install Part 2 ==============="
|
||||
echo "========================================================="
|
||||
echo "Shinobi - Database Installation"
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagreeData
|
||||
if [ "$mysqlagreeData" = "y" ]; then
|
||||
echo "Shinobi will now use root for database installation..."
|
||||
echo "What is your SQL Username?"
|
||||
read sqluser
|
||||
echo "What is your SQL Password?"
|
||||
read sqlpass
|
||||
echo "You may now be asked for your Administator (root for Mac OS, not MySQL) password"
|
||||
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
|
||||
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
|
||||
echo "Shinobi - Do you want to create a new user for viewing and managing cameras in Shinobi? You can do this later in the Superuser panel."
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlDefaultData
|
||||
if [ "$mysqlDefaultData" = "y" ]; then
|
||||
escapeReplaceQuote='\\"'
|
||||
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
|
||||
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
|
||||
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
|
||||
userDetails='{"days":"10"}'
|
||||
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
echo $userDetailsNew
|
||||
apiIP='0.0.0.0'
|
||||
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
|
||||
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
rm sql/default_user.sql || true
|
||||
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
|
||||
sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
|
||||
echo "The following details will be shown again at the end of the installation."
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
|
||||
fi
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Install NPM Libraries"
|
||||
sudo npm install
|
||||
echo "============="
|
||||
echo "Shinobi - Install PM2"
|
||||
sudo npm install pm2 -g
|
||||
if [ ! -e "./conf.json" ]; then
|
||||
sudo 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
|
||||
fi
|
||||
echo "Shinobi - Finished"
|
||||
touch INSTALL/installed.txt
|
||||
sudo chmod -R 755 .
|
||||
echo "=====================================" > INSTALL/installed.txt
|
||||
echo "======= Login Credentials =======" >> INSTALL/installed.txt
|
||||
echo "|| Username : $userEmail" >> INSTALL/installed.txt
|
||||
echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt
|
||||
echo "|| API Key : $apiKey" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
echo "Shinobi - Start Shinobi and set to start on boot?"
|
||||
echo "(y)es or (N)o"
|
||||
read startShinobi
|
||||
if [ "$startShinobi" = "y" ]; then
|
||||
sudo pm2 start camera.js
|
||||
sudo pm2 startup
|
||||
sudo pm2 save
|
||||
sudo pm2 list
|
||||
fi
|
||||
echo "details written to INSTALL/installed.txt"
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
50
INSTALL/macos.sh
Normal file
50
INSTALL/macos.sh
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
echo "========================================================="
|
||||
echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!=="
|
||||
echo "=================== Mac OS Install Part 1 ==============="
|
||||
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 "============="
|
||||
echo "Shinobi - Do you want to Install Node.js?"
|
||||
echo "(y)es or (N)o"
|
||||
read nodejsinstall
|
||||
if [ "$nodejsinstall" = "y" ]; then
|
||||
curl -o node-v8.9.3.pkg https://nodejs.org/dist/v8.9.3/node-v8.9.3.pkg
|
||||
sudo installer -pkg node-v8.9.3.pkg -target /
|
||||
rm node-v8.9.3.pkg
|
||||
sudo ln -s /usr/local/bin/node /usr/bin/nodejs
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install FFmpeg?"
|
||||
echo "(y)es or (N)o"
|
||||
read ffmpeginstall
|
||||
if [ "$ffmpeginstall" = "y" ]; then
|
||||
echo "Shinobi - Installing FFmpeg"
|
||||
curl -o ffmpeg.zip https://cdn.shinobi.video/installers/ffmpeg-3.4.1-macos.zip
|
||||
sudo unzip ffmpeg.zip
|
||||
sudo rm ffmpeg.zip
|
||||
sudo mv ffmpeg-3.4.1-macos/ffmpeg /usr/bin/ffmpeg
|
||||
sudo mv ffmpeg-3.4.1-macos/ffplay /usr/bin/ffplay
|
||||
sudo mv ffmpeg-3.4.1-macos/ffprobe /usr/bin/ffprobe
|
||||
sudo mv ffmpeg-3.4.1-macos/ffserver /usr/bin/ffserver
|
||||
sudo chmod +x /usr/local/bin/ffmpeg
|
||||
sudo chmod +x /usr/local/bin/ffplay
|
||||
sudo chmod +x /usr/local/bin/ffprobe
|
||||
sudo chmod +x /usr/local/bin/ffserver
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install MySQL? Choose No if you have MySQL or MySQL already."
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagree
|
||||
if [ "$mysqlagree" = "y" ]; then
|
||||
echo "Shinobi - Installing MySQL"
|
||||
bash <(curl -Ls http://git.io/eUx7rg)
|
||||
fi
|
||||
echo "============="
|
||||
echo "============="
|
||||
echo "You must now close this terminal window and reopen it."
|
||||
echo "Reopen the Shinobi folder and run"
|
||||
echo "sudo sh INSTALL/macos-part2.sh"
|
||||
echo "============="
|
||||
echo "============="
|
33
INSTALL/now.sh
Normal file
33
INSTALL/now.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
echo "Shinobi Installer"
|
||||
echo "========"
|
||||
echo "Select your OS"
|
||||
echo "If your OS is not on the list please refer to the docs."
|
||||
echo "========"
|
||||
echo "1. Ubuntu"
|
||||
echo "2. CentOS"
|
||||
echo "3. MacOS"
|
||||
echo "4. FreeBSD"
|
||||
echo "========"
|
||||
read oschoicee
|
||||
case $oschoicee in
|
||||
"1")
|
||||
chmod +x INSTALL/ubuntu.sh
|
||||
sh INSTALL/ubuntu.sh
|
||||
;;
|
||||
"2")
|
||||
chmod +x INSTALL/centos.sh
|
||||
INSTALL/centos.sh
|
||||
;;
|
||||
"3")
|
||||
chmod +x INSTALL/macos.sh
|
||||
INSTALL/macos.sh
|
||||
;;
|
||||
"4")
|
||||
chmod +x INSTALL/freebsd.sh
|
||||
INSTALL/freebsd.sh
|
||||
;;
|
||||
*)
|
||||
echo "Choice not found."
|
||||
;;
|
||||
esac
|
31
INSTALL/openalpr-gpu-easy.sh
Normal file
31
INSTALL/openalpr-gpu-easy.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Install prerequisites
|
||||
# this includes all the ones missing from OpenALPR's guide.
|
||||
sudo apt install libtesseract-dev git cmake build-essential libleptonica-dev -y
|
||||
sudo apt install liblog4cplus-dev libcurl3-dev -y
|
||||
sudo apt install libleptonica-dev -y
|
||||
sudo apt install libcurl4-openssl-dev -y
|
||||
sudo apt install liblog4cplus-dev -y
|
||||
sudo apt install beanstalkd -y
|
||||
sudo apt install openjdk-8-jdk -y
|
||||
|
||||
# Clone the latest code from GitHub
|
||||
git clone https://github.com/openalpr/openalpr.git
|
||||
|
||||
# Setup the build directory
|
||||
cd openalpr/src
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# setup the compile environment
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc –DCOMPILE_GPU=1 -D WITH_GPU_DETECTOR=ON ..
|
||||
|
||||
# compile the library
|
||||
make
|
||||
|
||||
# Install the binaries/libraries to your local system (prefix is /usr)
|
||||
sudo make install
|
||||
|
||||
# Test the library
|
||||
wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
|
||||
alpr lp.jpg
|
||||
rm lp.jpg
|
3
INSTALL/openalpr-opencl.sh
Normal file
3
INSTALL/openalpr-opencl.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
sudo apt-get update && sudo apt install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev
|
||||
|
||||
git clone https://github.com/openalpr/openalpr.git
|
101
INSTALL/opencv-cuda.sh
Normal file
101
INSTALL/opencv-cuda.sh
Normal file
|
@ -0,0 +1,101 @@
|
|||
#!/bin/bash
|
||||
#dlib
|
||||
echo "================="
|
||||
echo "Installing OpenCV"
|
||||
echo "================="
|
||||
if [ $(dpkg-query -W -f='${Status}' git 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||
echo "Installing Git..."
|
||||
apt install git -y;
|
||||
fi
|
||||
sudo apt-get install libopenblas-dev -y
|
||||
if [ ! -e "./opencv" ]; then
|
||||
echo "Downloading OpenCV..."
|
||||
git clone https://github.com/opencv/opencv.git
|
||||
cd opencv
|
||||
git checkout 3.4.0
|
||||
cd ..
|
||||
fi
|
||||
if [ ! -e "./opencv_contrib" ]; then
|
||||
echo "Downloading OpenCV Modules..."
|
||||
git clone https://github.com/opencv/opencv_contrib.git
|
||||
cd opencv_contrib
|
||||
git checkout 3.4.0
|
||||
cd ..
|
||||
fi
|
||||
echo "Opening OpenCV Directory..."
|
||||
cd opencv
|
||||
if [ ! -e "./build" ]; then
|
||||
echo "Creating OpenCV Build Directory..."
|
||||
mkdir build
|
||||
fi
|
||||
echo "Entering OpenCV Build Directory..."
|
||||
cd build
|
||||
echo "*****************"
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
flavor=$(cat /var/log/installer/media-info)
|
||||
echo "$flavor"
|
||||
echo "*****************"
|
||||
echo "Adding Additional Repository"
|
||||
echo "http://security.ubuntu.com/ubuntu"
|
||||
if [ "$flavor" = *"Artful"* ]; then
|
||||
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu artful-security main"
|
||||
fi
|
||||
if [ "$flavor" = *"Zesty"* ]; then
|
||||
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu zesty-security main"
|
||||
fi
|
||||
if [ "$flavor" = *"Xenial"* ]; then
|
||||
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
|
||||
fi
|
||||
if [ "$flavor" = *"Trusty"* ]; then
|
||||
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu trusty-security main"
|
||||
fi
|
||||
echo "Downloading Libraries"
|
||||
sudo apt-get install libjpeg-dev libpango1.0-dev libgif-dev build-essential gcc-6 g++-6 -y;
|
||||
sudo apt-get install libxvidcore-dev libx264-dev -y;
|
||||
sudo apt-get install libatlas-base-dev gfortran -y;
|
||||
|
||||
sudo apt install build-essential cmake pkg-config unzip ffmpeg qtbase5-dev python-dev python3-dev python-numpy python3-numpy libhdf5-dev libgtk-3-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libtiff5-dev libtesseract-dev -y;
|
||||
|
||||
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev libpng16-16 libpng-dev libv4l-dev libtbb-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev v4l-utils libleptonica-dev -y
|
||||
|
||||
echo "Setting CUDA Paths"
|
||||
export LD_LIBRARY_PATH=/usr/local/cuda/lib
|
||||
export PATH=$PATH:/usr/local/cuda/bin
|
||||
echo "Configure OpenCV Build"
|
||||
|
||||
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_NVCUVID=ON -D FORCE_VTK=ON -D WITH_XINE=ON -D WITH_CUDA=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D WITH_OPENCL=ON -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES --expt-relaxed-constexpr" -D WITH_GDAL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D CXXFLAGS="-std=c++11" -DCMAKE_CXX_COMPILER=g++-6 -DCMAKE_C_COMPILER=gcc-6 ..
|
||||
|
||||
echo "Start OpenCV Build"
|
||||
make -j "$(nproc)"
|
||||
echo "Install OpenCV Build"
|
||||
sudo make install
|
||||
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
|
||||
sudo ldconfig
|
||||
sudo apt-get update
|
||||
fi
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
yum install -y \
|
||||
protobuf-devel \
|
||||
leveldb-devel \
|
||||
snappy-devel \
|
||||
opencv-devel \
|
||||
boost-devel \
|
||||
hdf5-devel \
|
||||
gflags-devel \
|
||||
glog-devel \
|
||||
lmdb-devel \
|
||||
cmake
|
||||
fi
|
||||
echo "Leaving OpenCV Directory"
|
||||
cd ../..
|
||||
|
||||
echo "============="
|
||||
echo "Done installing OpenCV!"
|
||||
echo "============="
|
||||
echo "Delete OpenCV source files? This will save a lot of space but it will be more tedious to uninstall OpenCV later."
|
||||
echo "(y)es or (N)o"
|
||||
read opencvuninstall
|
||||
if [ "$opencvuninstall" = "y" ] || [ "$opencvuninstall" = "Y" ]; then
|
||||
rm -rf opencv
|
||||
rm -rf opencv_contrib
|
||||
fi
|
10
INSTALL/shinobi
Normal file
10
INSTALL/shinobi
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
installationDirectory="/home/Shinobi"
|
||||
if [ -e "$installationDirectory/INSTALL/installed.txt" ]; then
|
||||
echo "Starting Shinobi"
|
||||
pm2 start $installationDirectory/camera.js
|
||||
pm2 start $installationDirectory/cron.js
|
||||
fi
|
||||
if [ ! -e "$installationDirectory/INSTALL/installed.txt" ]; then
|
||||
chmod +x $installationDirectory/INSTALL/now.sh&&INSTALL/now.sh
|
||||
fi
|
11
INSTALL/shinobi.service
Normal file
11
INSTALL/shinobi.service
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=ShinobiCCTV
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/home/Shinobi
|
||||
Type=forking
|
||||
ExecStart=/bin/bash INSTALL/start.sh
|
||||
KillMode=process
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
9
INSTALL/start.sh
Normal file
9
INSTALL/start.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
if [ -e "INSTALL/installed.txt" ]; then
|
||||
echo "Starting Shinobi"
|
||||
pm2 start camera.js
|
||||
pm2 start cron.js
|
||||
fi
|
||||
if [ ! -e "INSTALL/installed.txt" ]; then
|
||||
chmod +x INSTALL/now.sh&&INSTALL/now.sh
|
||||
fi
|
175
INSTALL/ubuntu-easyinstall.sh
Normal file
175
INSTALL/ubuntu-easyinstall.sh
Normal file
|
@ -0,0 +1,175 @@
|
|||
#!/bin/bash
|
||||
echo "Shinobi - Do you want to Install Node.js?"
|
||||
echo "(y)es or (N)o"
|
||||
read nodejsinstall
|
||||
if [ "$nodejsinstall" = "y" ]; then
|
||||
wget https://deb.nodesource.com/setup_8.x
|
||||
chmod +x setup_8.x
|
||||
./setup_8.x
|
||||
sudo apt install nodejs -y
|
||||
rm setup_8.x
|
||||
fi
|
||||
|
||||
#Detect Ubuntu Version
|
||||
echo "============="
|
||||
echo " Detecting Ubuntu Version"
|
||||
echo "============="
|
||||
declare -i getubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1)
|
||||
echo "============="
|
||||
echo " Ubuntu Version: $getubuntuversion"
|
||||
echo "============="
|
||||
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
|
||||
echo "============="
|
||||
else
|
||||
echo "============="
|
||||
echo "Shinobi - Installing FFMPEG"
|
||||
sudo apt install ffmpeg libav-tools x264 x265 -y
|
||||
echo "============="
|
||||
fi
|
||||
|
||||
# Install MariaDB
|
||||
echo "Shinobi - Do you want to Install MariaDB? Choose No if you have MySQL."
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagree
|
||||
if [ "$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
|
||||
apt install mariadb-server -y
|
||||
service mysql start
|
||||
fi
|
||||
|
||||
# Make sure files have correct perms
|
||||
chmod -R 755 .
|
||||
|
||||
# Database Installation
|
||||
#Check If Mysql-Server is already installed
|
||||
|
||||
echo "============="
|
||||
echo "Checking for mysql-server"
|
||||
echo "============="
|
||||
dpkg -s mysql-server &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "+====================================+"
|
||||
echo "| Warning MYSQL SERVER IS INSTALLED! |"
|
||||
echo "+====================================+"
|
||||
echo "| DO YOU WANT TO INSTALL MariaDB? |"
|
||||
echo "| This will remove MYSQL-Server! |"
|
||||
echo "+====================================+"
|
||||
echo "Shinobi - Do you want to Install MariaDB?"
|
||||
echo "(y)es or (N)o"
|
||||
read installmariadb
|
||||
if [ "$installmariadb" = "y" ]; then
|
||||
echo "+=============================================+"
|
||||
echo "| This will DESTORY ALL DATA ON MYSQL SERVER! |"
|
||||
echo "+=============================================+"
|
||||
echo "Please type the following to continue"
|
||||
echo "DESTORY!"
|
||||
read mysqlagree
|
||||
if [ "$mysqlagree" = "DESTORY!" ]; 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
|
||||
#Create my.cnf file
|
||||
echo "[client]" >> ~/.my.cnf
|
||||
echo "user=root" >> ~/.my.cnf
|
||||
echo "password=$sqlpass" >> ~/.my.cnf
|
||||
chmod 755 ~/.my.cnf
|
||||
apt install mariadb-server
|
||||
service mysql start
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Shinobi - Do you want to Install MariaDB?"
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagree
|
||||
if [ "$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
|
||||
echo "[client]" >> ~/.my.cnf
|
||||
echo "user=root" >> ~/.my.cnf
|
||||
echo "password=$sqlpass" >> ~/.my.cnf
|
||||
chmod 755 ~/.my.cnf
|
||||
apt install mariadb-server -y
|
||||
service mysql start
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod -R 755 .
|
||||
echo "Shinobi - Database Installation"
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlagreeData
|
||||
if [ "$mysqlagreeData" = "y" ]; then
|
||||
mysql -e "source sql/user.sql" || true
|
||||
mysql -e "source sql/framework.sql" || true
|
||||
echo "Shinobi - Do you want to Install Default Data (default_data.sql)?"
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlDefaultData
|
||||
if [ "$mysqlDefaultData" = "y" ]; then
|
||||
escapeReplaceQuote='\\"'
|
||||
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
|
||||
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
|
||||
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
|
||||
userDetails='{"days":"10"}'
|
||||
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
echo $userDetailsNew
|
||||
apiIP='0.0.0.0'
|
||||
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
|
||||
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
rm sql/default_user.sql || true
|
||||
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
|
||||
mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
|
||||
echo "====================================="
|
||||
echo "=======!! Login Credentials !!======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install NPM Libraries
|
||||
echo "============="
|
||||
echo "Shinobi - Install NPM Libraries"
|
||||
npm install
|
||||
echo "============="
|
||||
|
||||
#Install PM2
|
||||
echo "Shinobi - Install PM2"
|
||||
sudo npm install pm2 -g
|
||||
if [ ! -e "./conf.json" ]; then
|
||||
cp conf.sample.json conf.json
|
||||
fi
|
||||
if [ ! -e "./super.json" ]; then
|
||||
getip=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
|
||||
echo "Admin panel default url: http://$getip:8080/super"
|
||||
echo "Default Superuser : admin@shinobi.video"
|
||||
echo "Default Password : admin"
|
||||
cp super.sample.json super.json
|
||||
fi
|
||||
echo "Shinobi - Finished"
|
||||
touch INSTALL/installed.txt
|
||||
echo "Shinobi - Start Shinobi?"
|
||||
echo "(y)es or (N)o"
|
||||
read startShinobi
|
||||
if [ "$startShinobi" = "y" ]; then
|
||||
pm2 start camera.js
|
||||
pm2 start cron.js
|
||||
pm2 list
|
||||
fi
|
202
INSTALL/ubuntu.sh
Normal file
202
INSTALL/ubuntu.sh
Normal file
|
@ -0,0 +1,202 @@
|
|||
#!/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
|
||||
sudo cp conf.sample.json conf.json
|
||||
fi
|
||||
if [ ! -e "./super.json" ]; then
|
||||
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 createSuperJson
|
||||
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
|
||||
echo "Shinobi - Do you want to Install Node.js?"
|
||||
echo "(y)es or (N)o"
|
||||
read nodejsinstall
|
||||
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
|
||||
wget https://deb.nodesource.com/setup_8.x
|
||||
chmod +x setup_8.x
|
||||
./setup_8.x
|
||||
sudo apt install nodejs -y
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to Install FFMPEG?"
|
||||
echo "(y)es or (N)o"
|
||||
read ffmpeginstall
|
||||
if [ "$ffmpeginstall" = "y" ] || [ "$ffmpeginstall" = "Y" ]; then
|
||||
echo "Shinobi - Do you want to Install FFMPEG with `apt` or download a static version provided with `npm`?"
|
||||
echo "(a)pt or (N)pm"
|
||||
echo "Press [ENTER] for default (npm)"
|
||||
read ffmpegstaticinstall
|
||||
if [ "$ffmpegstaticinstall" = "a" ] || [ "$ffmpegstaticinstall" = "A" ]; then
|
||||
#Detect Ubuntu Version
|
||||
echo "============="
|
||||
echo " Detecting Ubuntu Version"
|
||||
echo "============="
|
||||
declare -i getubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1)
|
||||
echo "============="
|
||||
echo " Ubuntu Version: $getubuntuversion"
|
||||
echo "============="
|
||||
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
|
||||
echo "============="
|
||||
else
|
||||
echo "============="
|
||||
echo "Shinobi - Installing FFMPEG"
|
||||
sudo apt install ffmpeg -y
|
||||
echo "============="
|
||||
fi
|
||||
else
|
||||
sudo npm install ffmpeg-static
|
||||
fi
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Do you want to use MariaDB or SQLite3?"
|
||||
echo "SQLite3 is better for small installs"
|
||||
echo "MariaDB (MySQL) is better for large installs"
|
||||
echo "(S)QLite3 or (M)ariaDB?"
|
||||
echo "Press [ENTER] for default (MariaDB)"
|
||||
read sqliteormariadb
|
||||
if [ "$sqliteormariadb" = "S" ] || [ "$sqliteormariadb" = "s" ]; then
|
||||
sudo npm install jsonfile
|
||||
sudo apt-get install sqlite3 libsqlite3-dev -y
|
||||
sudo npm install sqlite3
|
||||
node ./tools/modifyConfiguration.js databaseType=sqlite3
|
||||
if [ ! -e "./shinobi.sqlite" ]; then
|
||||
echo "Creating shinobi.sqlite for SQLite3..."
|
||||
sudo cp sql/shinobi.sample.sqlite shinobi.sqlite
|
||||
else
|
||||
echo "shinobi.sqlite already exists. Continuing..."
|
||||
fi
|
||||
else
|
||||
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
|
||||
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
|
||||
sqluser="root"
|
||||
fi
|
||||
if [ ! "$mysqlagree" = "y" ]; then
|
||||
echo "What is your SQL Username?"
|
||||
read sqluser
|
||||
echo "What is your SQL Password?"
|
||||
read sqlpass
|
||||
fi
|
||||
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
|
||||
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
|
||||
echo "Shinobi - Do you want to create a new user for viewing and managing cameras in Shinobi? You can do this later in the Superuser panel."
|
||||
echo "(y)es or (N)o"
|
||||
read mysqlDefaultData
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
escapeReplaceQuote='\\"'
|
||||
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
|
||||
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
|
||||
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
|
||||
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
|
||||
userDetails='{"days":"10"}'
|
||||
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
echo $userDetailsNew
|
||||
apiIP='0.0.0.0'
|
||||
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
|
||||
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
|
||||
rm sql/default_user.sql || true
|
||||
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
|
||||
sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
|
||||
echo "The following details will be shown again at the end of the installation."
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "============="
|
||||
echo "Shinobi - Install NPM Libraries"
|
||||
sudo npm install
|
||||
echo "============="
|
||||
echo "Shinobi - Install PM2"
|
||||
sudo npm install pm2 -g
|
||||
echo "Shinobi - Finished"
|
||||
sudo chmod -R 755 .
|
||||
touch INSTALL/installed.txt
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
echo "=====================================" > INSTALL/installed.txt
|
||||
echo "======= Login Credentials =======" >> INSTALL/installed.txt
|
||||
echo "|| Username : $userEmail" >> INSTALL/installed.txt
|
||||
echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt
|
||||
echo "|| API Key : $apiKey" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
echo "=====================================" >> INSTALL/installed.txt
|
||||
fi
|
||||
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
|
||||
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
|
||||
echo "details written to INSTALL/installed.txt"
|
||||
echo "====================================="
|
||||
echo "======= Login Credentials ======="
|
||||
echo "|| Username : $userEmail"
|
||||
echo "|| Password : $userPasswordPlain"
|
||||
echo "|| API Key : $apiKey"
|
||||
echo "====================================="
|
||||
echo "====================================="
|
||||
fi
|
||||
if [ ! "$sqliteormariadb" = "M" ] && [ ! "$sqliteormariadb" = "m" ]; then
|
||||
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 "====================================="
|
||||
else
|
||||
echo "+=================================+"
|
||||
echo "||===== Install Completed =====||"
|
||||
echo "|| Access the main Shinobi panel at http://$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'):8080 in your web browser."
|
||||
echo "+=================================+"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue