├── .env ├── .gitattributes ├── .gitignore ├── .npmignore ├── COPYING ├── INSTALL.md ├── INSTALL ├── .gitignore ├── README.md ├── autoinstall-ubuntu-latest.sh ├── autoinstall-ubuntu-stable.sh ├── centos.sh ├── cuda9-part1.sh ├── cuda9-part2-after-reboot.sh ├── ffmpeg.sh ├── freebsd.sh ├── installDatabase.js ├── macos-part2.sh ├── macos.sh ├── now.sh ├── openalpr-gpu-easy.sh ├── opencv-cuda.sh ├── shinobi.service ├── start.sh ├── ubuntu-easyinstall.sh └── ubuntu.sh ├── LICENSE ├── README.md ├── UPDATE.sh ├── camera.js ├── conf.sample.json ├── cron.js ├── definitions └── en_CA.json ├── index.html ├── languages ├── ar.json ├── bn.json ├── de.json ├── en_CA.json ├── fr.json ├── ja.json ├── pt_BR.json ├── ru.json └── zh.json ├── package.json ├── plugins ├── .gitignore ├── child │ ├── .gitignore │ ├── child.js │ ├── conf.child.sample.json │ └── conf.json.default ├── microsoft │ ├── conf.sample.json │ └── shinobi-ms-vision.js ├── motion │ ├── .gitignore │ ├── INSTALL.sh │ ├── README.md │ ├── conf.sample.json │ ├── libs │ │ └── clusterPoints.js │ ├── shinobi-motion-pixel.js │ └── shinobi-motion.js ├── openalpr │ ├── .gitignore │ ├── README.md │ ├── conf.sample.json │ ├── package.json │ └── shinobi-openalpr.js └── opencv │ ├── .gitignore │ ├── conf.sample.json │ ├── shinobi-opencv-no-motion.js │ └── shinobi-opencv.js ├── sql ├── .gitignore ├── database.sql ├── default_data.sql ├── docker │ └── 01-framework.sql ├── framework.sql ├── mssql │ ├── default_data.sql │ ├── framework.sql │ └── user.sql ├── postgresql │ ├── default_data.sql │ ├── framework.sql │ └── user.sql ├── shinobi.sample.sqlite ├── sqlite3 │ └── framework.sql ├── sqllog.txt ├── tables.sql ├── update-1-1-2017.sql ├── update-13-7-2017.sql ├── update-17-5-2017.sql ├── update-2-2-2017.sql ├── update-26-08-2017.sql ├── update-5-6-2017.sql └── user.sql ├── super.sample.json ├── tools ├── addVideos.js.disabled └── translateLanguageFile.js └── web ├── libs ├── .gitignore ├── css │ ├── bootstrap-table.min.css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── c3.css │ ├── circles.css │ ├── daterangepicker.css │ ├── daterangepicker.scss │ ├── font-awesome.css │ ├── font-awesome.min.css │ ├── fullcalendar.min.css │ ├── fullcalendar.print.css │ ├── login.css │ ├── main.dash2.css │ ├── material.min.css │ ├── material.min.css.map │ ├── material.style.css │ ├── pnotify.custom.min.css │ ├── poseidon.css │ └── vbox.css ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ └── fontawesome-webfont.woff2 ├── img │ ├── bg.jpg │ ├── demo.jpg │ └── icon │ │ ├── README.md │ │ ├── apple-touch-icon-114x114.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-144x144.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-57x57.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-72x72.png │ │ ├── apple-touch-icon-76x76.png │ │ ├── circle-text.png │ │ ├── favicon-128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-196x196.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── favicon.ico │ │ ├── mstile-144x144.png │ │ ├── mstile-150x150.png │ │ ├── mstile-310x150.png │ │ ├── mstile-310x310-circle.png │ │ ├── mstile-310x310.png │ │ └── mstile-70x70.png ├── js │ ├── Chart.js │ ├── bootstrap-table-locale-all.min.js │ ├── bootstrap-table.min.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── c3.js │ ├── clock.js │ ├── clusterPoints.js │ ├── d3.v3.min.js │ ├── dash.mediaplayer.min.js │ ├── daterangepicker.js │ ├── flv.min.js │ ├── flv.min.js.map │ ├── flv.shinobi.js │ ├── fullcalendar.min.js │ ├── gcal.js │ ├── hls.min.js │ ├── jquery-ui.min.js │ ├── jquery.canvasAreaDraw.js │ ├── jquery.min.js │ ├── jquery.serialize.js │ ├── livestamp.min.js │ ├── locale-all.js │ ├── main.dash2.js │ ├── material.min.js │ ├── material.min.js.map │ ├── menu.js │ ├── moment.js │ ├── morris.min.js │ ├── npm.js │ ├── placeholder.js │ ├── pnotify.custom.min.js │ ├── poseidon.js │ └── socket.io.js ├── less │ ├── animated.less │ ├── bordered-pulled.less │ ├── core.less │ ├── fixed-width.less │ ├── font-awesome.less │ ├── icons.less │ ├── larger.less │ ├── list.less │ ├── mixins.less │ ├── path.less │ ├── rotated-flipped.less │ ├── screen-reader.less │ ├── stacked.less │ └── variables.less ├── scss │ ├── _animated.scss │ ├── _bordered-pulled.scss │ ├── _core.scss │ ├── _fixed-width.scss │ ├── _icons.scss │ ├── _larger.scss │ ├── _list.scss │ ├── _mixins.scss │ ├── _path.scss │ ├── _rotated-flipped.scss │ ├── _screen-reader.scss │ ├── _stacked.scss │ ├── _variables.scss │ └── font-awesome.scss └── themes │ └── Enterprise Blue │ └── style.css └── pages ├── admin.ejs ├── blocks ├── api.ejs ├── confirm.ejs ├── filters.ejs ├── github.ejs ├── header.ejs ├── help.ejs ├── logs.ejs ├── mainpermissions.ejs ├── monitoredit.ejs ├── multimon.ejs ├── powervideo.ejs ├── probe.ejs ├── region.ejs ├── settings.ejs ├── subpermissions.ejs ├── timelapse.ejs └── videoview.ejs ├── dashcam.ejs ├── embed.ejs ├── factor.ejs ├── home.ejs ├── index.ejs ├── mjpeg.ejs ├── script.ejs ├── streamer.ejs └── super.ejs /.env: -------------------------------------------------------------------------------- 1 | MYSQL_HOST=db 2 | MYSQL_DATABASE=ccio 3 | MYSQL_USER=ccio 4 | MYSQL_PASSWORD=shinobi 5 | MYSQL_ROOT_PASSWORD=shinobiroot 6 | MYSQL_VOLUME_DIR="./dbdata" 7 | ADMIN_PASSWORD=admin 8 | TIMEZONE_OFFSET='-0800' 9 | VIDEOS_VOLUME_DIR="./videos" 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | docker-entrypoint.sh text eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | videos 3 | events 4 | frames 5 | web.old 6 | .DS_Store 7 | .vagrant 8 | conf.json 9 | super.json 10 | dbdata 11 | npm-debug.log 12 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | conf.json -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | This software is licensed under the GPLv3 and AGPLv3 2 | 3 | GPLv3 : https://www.gnu.org/licenses/gpl-3.0.en.html 4 | AGPLv3 : https://www.gnu.org/licenses/agpl-3.0.en.html -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | **Detailed Instructions for multiple Operating Systems can now be found in the docs.** 2 | 3 | https://shinobi.video/docs/start -------------------------------------------------------------------------------- /INSTALL/.gitignore: -------------------------------------------------------------------------------- 1 | installed.txt -------------------------------------------------------------------------------- /INSTALL/README.md: -------------------------------------------------------------------------------- 1 | #### Fast Install (The Ninja Way) 2 | 3 | 1. Become `root` to use the installer and run Shinobi. Use one of the following to do so. 4 | 5 | - Ubuntu 17.04, 17.10 6 | - `sudo su` 7 | - CentOS 7 8 | - `su` 9 | - MacOS 10.7(+) 10 | - `su` 11 | 2. Download and run the installer. 12 | 13 | ``` 14 | bash <(curl -s https://raw.githubusercontent.com/ShinobiCCTV/Shinobi-Installer/master/shinobi-install.sh) 15 | ``` 16 | 17 | More info can be found here. https://shinobi.video/docs/start -------------------------------------------------------------------------------- /INSTALL/autoinstall-ubuntu-latest.sh: -------------------------------------------------------------------------------- 1 | apt install git -y 2 | git clone https://github.com/ShinobiCCTV/Shinobi.git -b dev Shinobi-dev 3 | cd Shinobi-dev 4 | chmod +x INSTALL/ubuntu-easyinstall.sh && INSTALL/ubuntu-easyinstall.sh 5 | bash INSTALL/ubuntu-easyinstall.sh -------------------------------------------------------------------------------- /INSTALL/autoinstall-ubuntu-stable.sh: -------------------------------------------------------------------------------- 1 | apt install git -y 2 | git clone https://github.com/ShinobiCCTV/Shinobi.git Shinobi 3 | cd Shinobi 4 | chmod +x INSTALL/ubuntu-easyinstall.sh && INSTALL/ubuntu-easyinstall.sh 5 | bash INSTALL/ubuntu-easyinstall.sh -------------------------------------------------------------------------------- /INSTALL/cuda9-part1.sh: -------------------------------------------------------------------------------- 1 | sudo add-apt-repository ppa:graphics-drivers/ppa -y 2 | sudo apt update -y 3 | sudo apt install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev -y 4 | sudo apt install gcc-6 -y 5 | sudo apt install g++-6 -y 6 | wget https://cdn.shinobi.video/installers/cuda9-part2-after-reboot.sh -O cuda9-part2-after-reboot.sh 7 | sudo chmod +x ./cuda9-part2-after-reboot.sh 8 | wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run -O cuda_9.run 9 | sudo chmod +x cuda_9.run 10 | sudo echo "blacklist amd76x_edac" >> /etc/modprobe.d/blacklist.conf 11 | sudo echo "blacklist vga16fb" >> /etc/modprobe.d/blacklist.conf 12 | sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf 13 | sudo echo "blacklist rivafb" >> /etc/modprobe.d/blacklist.conf 14 | sudo echo "blacklist nvidiafb" >> /etc/modprobe.d/blacklist.conf 15 | sudo echo "blacklist rivatv" >> /etc/modprobe.d/blacklist.conf 16 | sudo update-initramfs -u 17 | echo "Now you need to reboot and run the next part." 18 | echo "Do after the reboot inside this directory : ./cuda9-part2-after-reboot.sh" -------------------------------------------------------------------------------- /INSTALL/cuda9-part2-after-reboot.sh: -------------------------------------------------------------------------------- 1 | sudo service lightdm stop 2 | sudo init 3 3 | sudo ./cuda_9.run -- override 4 | sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc 5 | sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++ 6 | nvidia-smi -------------------------------------------------------------------------------- /INSTALL/ffmpeg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "=============" 3 | echo "Install FFMPEG" 4 | echo "What build of FFMPEG do you require?" 5 | echo "If you don't know check your CPU specs for a hint." 6 | echo "- 32bit" 7 | echo "- 64bit" 8 | echo "- armel-32bit" 9 | echo "- armhf-32bit" 10 | read ffmpegbuild 11 | wget "https://s3.amazonaws.com/cloudcamio/ffmpeg-release-$ffmpegbuild-static.tar.xz" 12 | tar xf "ffmpeg-release-$ffmpegbuild-static.tar.xz" 13 | mv "ffmpeg-3.3-$ffmpegbuild-static/ffmpeg" "/usr/bin/ffmpeg" 14 | mv "ffmpeg-3.3-$ffmpegbuild-static/ffmpeg-10bit" "/usr/bin/ffmpeg-10bit" 15 | mv "ffmpeg-3.3-$ffmpegbuild-static/ffprobe" "/usr/bin/ffprobe" 16 | mv "ffmpeg-3.3-$ffmpegbuild-static/ffserver" "/usr/bin/ffserver" 17 | chmod +x /usr/bin/ffmpeg 18 | chmod +x /usr/bin/ffmpeg-10bit 19 | chmod +x /usr/bin/ffprobe 20 | chmod +x /usr/bin/ffserver 21 | rm -rf "ffmpeg-3.3-$ffmpegbuild-static" 22 | rm -rf "ffmpeg-release-$ffmpegbuild-static.tar.xz" 23 | -------------------------------------------------------------------------------- /INSTALL/freebsd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | echo "=========================================================" 3 | echo "==== Shinobi : The Open Source CCTV and NVR Solution ====" 4 | echo "=========================================================" 5 | echo "This script should run as root inside your jail from the root" 6 | echo "of the cloned git repository." 7 | echo "To answer yes type the letter (y) in lowercase and press ENTER." 8 | echo "Default is no (N). Skip any components you already have or don't need." 9 | echo "=============" 10 | echo "Shinobi - Do you want to Install Node.js?" 11 | echo "(y)es or (N)o" 12 | set nodejsinstall = $< 13 | if ( $nodejsinstall == "y" ) then 14 | pkg install -y node8 npm-node8 15 | endif 16 | echo "=============" 17 | echo "Shinobi - Do you want to Install FFMPEG?" 18 | echo "(y)es or (N)o" 19 | set ffmpeginstall = $< 20 | if ( $ffmpeginstall == "y" ) then 21 | pkg install -y ffmpeg libav x264 x265 22 | endif 23 | echo "=============" 24 | echo "Shinobi - Database Installation" 25 | echo "WARNING - This requires an existing and running mariadb service." 26 | echo "(y)es or (N)o" 27 | set mysqlagreeData = $< 28 | if ( $mysqlagreeData == "y" ) then 29 | echo "What is your SQL Username?" 30 | set sqluser = $< 31 | echo "What is your SQL Password?" 32 | set sqlpass = $< 33 | echo "What is your SQL Host?" 34 | set sqlhost = $< 35 | echo "Installing mariadb client..." 36 | pkg install -y mariadb102-client 37 | echo "Installing database schema..." 38 | mysql -h $sqlhost -u $sqluser -p$sqlpass -e "source sql/user.sql" || true 39 | mysql -h $sqlhost -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true 40 | echo "Shinobi - Use the /super endpoint to create your super user." 41 | endif 42 | echo "=============" 43 | echo "Shinobi - Install NPM Libraries" 44 | npm install 45 | echo "=============" 46 | echo "Shinobi - Install PM2" 47 | npm install pm2 -g 48 | if (! -e "./conf.json" ) then 49 | cp conf.sample.json conf.json 50 | endif 51 | if (! -e "./super.json" ) then 52 | echo "Default Superuser : admin@shinobi.video" 53 | echo "Default Password : admin" 54 | cp super.sample.json super.json 55 | endif 56 | echo "Shinobi - Start Shinobi?" 57 | echo "(y)es or (N)o" 58 | set startShinobi = $< 59 | if ( $startShinobi == "y" ) then 60 | set PM2BIN="$PWD/node_modules/pm2/bin" 61 | $PM2BIN/pm2 start camera.js 62 | $PM2BIN/pm2 start cron.js 63 | $PM2BIN/pm2 save 64 | $PM2BIN/pm2 list 65 | endif 66 | echo "Shinobi - Start on boot?" 67 | echo "(y)es or (N)o" 68 | set startupShinobi = $< 69 | if ( $startupShinobi == "y" ) then 70 | set PM2BIN="$PWD/node_modules/pm2/bin" 71 | $PM2BIN/pm2 startup rcd 72 | endif 73 | echo "Shinobi - Finished" 74 | -------------------------------------------------------------------------------- /INSTALL/installDatabase.js: -------------------------------------------------------------------------------- 1 | var knex = require('knex'); 2 | if(config.databaseType===undefined){config.databaseType='mysql'} 3 | 4 | var databaseOptions = { 5 | client: config.databaseType, 6 | connection: config.db, 7 | } 8 | if(databaseOptions.client.indexOf('sqlite')>-1){ 9 | databaseOptions.client = 'sqlite3'; 10 | databaseOptions.useNullAsDefault = true; 11 | } 12 | if(databaseOptions.client === 'sqlite3' && databaseOptions.connection.filename === undefined){ 13 | databaseOptions.connection.filename = __dirname+"/shinobi.sqlite" 14 | } 15 | s.databaseEngine = knex(databaseOptions) 16 | s.sqlQuery = function(query,values,onMoveOn,hideLog){ 17 | if(!values){values=[]} 18 | if(typeof values === 'function'){ 19 | var onMoveOn = values; 20 | var values = []; 21 | } 22 | if(!onMoveOn){onMoveOn=function(){}} 23 | return s.databaseEngine.raw(query,values) 24 | .asCallback(function(err,r){ 25 | if(err&&config.databaseLogs){ 26 | s.systemLog('s.sqlQuery QUERY',query) 27 | s.systemLog('s.sqlQuery ERROR',err) 28 | } 29 | if(onMoveOn) 30 | if(typeof onMoveOn === 'function'){ 31 | if(!r)r=[] 32 | onMoveOn(err,r) 33 | }else{ 34 | console.log(onMoveOn) 35 | } 36 | }) 37 | } -------------------------------------------------------------------------------- /INSTALL/macos-part2.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | echo "=========================================================" 4 | echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!==" 5 | echo "=================== Mac OS Install Part 2 ===============" 6 | echo "=========================================================" 7 | echo "Shinobi - Database Installation" 8 | echo "(y)es or (N)o" 9 | read mysqlagreeData 10 | if [ "$mysqlagreeData" = "y" ]; then 11 | echo "Shinobi - Use root for database installation?" 12 | echo "(y)es or (N)o" 13 | echo "What is your SQL Username?" 14 | read sqluser 15 | echo "What is your SQL Password?" 16 | read sqlpass 17 | echo "You may now be asked for your Administator (root for Mac OS, not MySQL) password" 18 | sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true 19 | sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true 20 | 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." 21 | echo "(y)es or (N)o" 22 | read mysqlDefaultData 23 | if [ "$mysqlDefaultData" = "y" ]; then 24 | escapeReplaceQuote='\\"' 25 | groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1) 26 | userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1) 27 | 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" 28 | userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1) 29 | userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}') 30 | userDetails='{"days":"10"}' 31 | userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g') 32 | echo $userDetailsNew 33 | apiIP='0.0.0.0' 34 | apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) 35 | 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"}' 36 | apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g') 37 | rm sql/default_user.sql || true 38 | 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" 39 | sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt" 40 | echo "The following details will be shown again at the end of the installation." 41 | echo "=====================================" 42 | echo "======= Login Credentials =======" 43 | echo "|| Username : $userEmail" 44 | echo "|| Password : $userPasswordPlain" 45 | echo "|| API Key : $apiKey" 46 | echo "=====================================" 47 | echo "=====================================" 48 | 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. **" 49 | fi 50 | fi 51 | echo "=============" 52 | echo "Shinobi - Install NPM Libraries" 53 | sudo npm install 54 | echo "=============" 55 | echo "Shinobi - Install PM2" 56 | sudo npm install pm2 -g 57 | if [ ! -e "./conf.json" ]; then 58 | sudo cp conf.sample.json conf.json 59 | fi 60 | if [ ! -e "./super.json" ]; then 61 | echo "Default Superuser : admin@shinobi.video" 62 | echo "Default Password : admin" 63 | sudo cp super.sample.json super.json 64 | fi 65 | echo "Shinobi - Finished" 66 | touch INSTALL/installed.txt 67 | sudo chmod -R 755 . 68 | echo "=====================================" > INSTALL/installed.txt 69 | echo "======= Login Credentials =======" >> INSTALL/installed.txt 70 | echo "|| Username : $userEmail" >> INSTALL/installed.txt 71 | echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt 72 | echo "|| API Key : $apiKey" >> INSTALL/installed.txt 73 | echo "=====================================" >> INSTALL/installed.txt 74 | echo "=====================================" >> INSTALL/installed.txt 75 | echo "Shinobi - Start Shinobi and set to start on boot?" 76 | echo "(y)es or (N)o" 77 | read startShinobi 78 | if [ "$startShinobi" = "y" ]; then 79 | sudo pm2 start camera.js 80 | sudo pm2 start cron.js 81 | sudo pm2 startup 82 | sudo pm2 save 83 | sudo pm2 list 84 | fi 85 | echo "details written to INSTALL/installed.txt" 86 | echo "=====================================" 87 | echo "======= Login Credentials =======" 88 | echo "|| Username : $userEmail" 89 | echo "|| Password : $userPasswordPlain" 90 | echo "|| API Key : $apiKey" 91 | echo "=====================================" 92 | echo "=====================================" -------------------------------------------------------------------------------- /INSTALL/macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "=========================================================" 3 | echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!==" 4 | echo "=================== Mac OS Install Part 1 ===============" 5 | echo "=========================================================" 6 | echo "To answer yes type the letter (y) in lowercase and press ENTER." 7 | echo "Default is no (N). Skip any components you already have or don't need." 8 | echo "=============" 9 | echo "Shinobi - Do you want to Install Node.js?" 10 | echo "(y)es or (N)o" 11 | read nodejsinstall 12 | if [ "$nodejsinstall" = "y" ]; then 13 | curl -o node-v8.9.3.pkg https://nodejs.org/dist/v8.9.3/node-v8.9.3.pkg 14 | sudo installer -pkg node-v8.9.3.pkg -target / 15 | rm node-v8.9.3.pkg 16 | sudo ln -s /usr/local/bin/node /usr/bin/nodejs 17 | fi 18 | echo "=============" 19 | echo "Shinobi - Do you want to Install FFmpeg?" 20 | echo "(y)es or (N)o" 21 | read ffmpeginstall 22 | if [ "$ffmpeginstall" = "y" ]; then 23 | echo "Shinobi - Installing FFmpeg" 24 | curl -o ffmpeg.zip https://cdn.shinobi.video/installers/ffmpeg-3.4.1-macos.zip 25 | sudo unzip ffmpeg.zip 26 | sudo rm ffmpeg.zip 27 | sudo mv ffmpeg-3.4.1-macos/ffmpeg /usr/bin/ffmpeg 28 | sudo mv ffmpeg-3.4.1-macos/ffplay /usr/bin/ffplay 29 | sudo mv ffmpeg-3.4.1-macos/ffprobe /usr/bin/ffprobe 30 | sudo mv ffmpeg-3.4.1-macos/ffserver /usr/bin/ffserver 31 | sudo chmod +x /usr/bin/ffmpeg 32 | sudo chmod +x /usr/bin/ffplay 33 | sudo chmod +x /usr/bin/ffprobe 34 | sudo chmod +x /usr/bin/ffserver 35 | fi 36 | echo "=============" 37 | echo "Shinobi - Do you want to Install MySQL? Choose No if you have MySQL or MySQL already." 38 | echo "(y)es or (N)o" 39 | read mysqlagree 40 | if [ "$mysqlagree" = "y" ]; then 41 | echo "Shinobi - Installing MySQL" 42 | bash <(curl -Ls http://git.io/eUx7rg) 43 | fi 44 | echo "=============" 45 | echo "=============" 46 | echo "You must now close this terminal window and reopen it." 47 | echo "Reopen the Shinobi folder and run" 48 | echo "chmod +x INSTALL/macos-part2.sh && INSTALL/macos-part2.sh" 49 | echo "=============" 50 | echo "=============" -------------------------------------------------------------------------------- /INSTALL/now.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Shinobi Installer" 3 | echo "========" 4 | echo "Select your OS" 5 | echo "If your OS is not on the list please refer to the docs." 6 | echo "========" 7 | echo "1. Ubuntu" 8 | echo "2. CentOS" 9 | echo "3. MacOS" 10 | echo "========" 11 | read oschoicee 12 | case $oschoicee in 13 | "1") 14 | chmod +x INSTALL/ubuntu.sh 15 | sh INSTALL/ubuntu.sh 16 | ;; 17 | "2") 18 | chmod +x INSTALL/centos.sh 19 | INSTALL/centos.sh 20 | ;; 21 | "3") 22 | chmod +x INSTALL/macos.sh 23 | INSTALL/macos.sh 24 | ;; 25 | *) 26 | echo "Choice not found." 27 | ;; 28 | esac -------------------------------------------------------------------------------- /INSTALL/openalpr-gpu-easy.sh: -------------------------------------------------------------------------------- 1 | # Install prerequisites 2 | # this includes all the ones missing from OpenALPR's guide. 3 | sudo apt install libopencv-dev libtesseract-dev git cmake build-essential libleptonica-dev -y 4 | sudo apt install liblog4cplus-dev libcurl3-dev -y 5 | sudo apt install libleptonica-dev -y 6 | sudo apt install libcurl4-openssl-dev -y 7 | sudo apt install liblog4cplus-dev -y 8 | sudo apt install beanstalkd -y 9 | sudo apt install openjdk-8-jdk -y 10 | 11 | # Clone the latest code from GitHub 12 | git clone https://github.com/openalpr/openalpr.git 13 | 14 | # Setup the build directory 15 | cd openalpr/src 16 | mkdir build 17 | cd build 18 | 19 | # setup the compile environment 20 | cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc –DCOMPILE_GPU=1 .. 21 | 22 | # compile the library 23 | make 24 | 25 | # Install the binaries/libraries to your local system (prefix is /usr) 26 | sudo make install 27 | 28 | # Test the library 29 | wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg 30 | alpr lp.jpg -------------------------------------------------------------------------------- /INSTALL/opencv-cuda.sh: -------------------------------------------------------------------------------- 1 | # OpenCV CUDA 2 | 3 | wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.0.zip 4 | wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.0.zip 5 | sudo apt-get install unzip -y 6 | 7 | sudo unzip opencv.zip -d tempOpenCV 8 | sudo unzip opencv_contrib.zip -d tempOpenCVContrib 9 | 10 | sudo mv tempOpenCV/opencv-3.4.0 opencv 11 | sudo mv tempOpenCVContrib/opencv_contrib-3.4.0 opencv_contrib 12 | sudo rm -rf tempOpenCV 13 | sudo rm -rf tempOpenCVContrib 14 | 15 | sudo apt install build-essential cmake git 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 16 | 17 | sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu zesty-security main" 18 | sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" 19 | sudo apt update 20 | sudo apt install libjasper1 libjasper-dev 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 libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev v4l-utils -y 21 | 22 | cd opencv 23 | mkdir release 24 | cd release 25 | 26 | cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_NVCUVID=ON -D FORCE_VTK=ON -D BUILD_DOCS=ON -D WITH_XINE=ON -D WITH_CUDA=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=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 .. 27 | 28 | make -j4 29 | sudo make install -------------------------------------------------------------------------------- /INSTALL/shinobi.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=ShinobiCCTV 3 | 4 | [Service] 5 | WorkingDirectory=/home/Shinobi 6 | Type=forking 7 | ExecStart=/bin/bash INSTALL/start.sh 8 | KillMode=process 9 | 10 | [Install] 11 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /INSTALL/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -e "INSTALL/installed.txt" ]; then 3 | echo "Starting Shinobi" 4 | pm2 start camera.js 5 | pm2 start cron.js 6 | fi 7 | if [ ! -e "INSTALL/installed.txt" ]; then 8 | chmod +x INSTALL/now.sh&&INSTALL/now.sh 9 | fi -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This software is licensed under the GPLv3 and AGPLv3 2 | 3 | GPLv3 : https://www.gnu.org/licenses/gpl-3.0.en.html 4 | AGPLv3 : https://www.gnu.org/licenses/agpl-3.0.en.html -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # We moved to GitLab! 2 | ## https://gitlab.com/Shinobi-Systems/Shinobi 3 | -------------------------------------------------------------------------------- /UPDATE.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | distro=$1 3 | if [ -z ${distro+x} ]; then 4 | distro='master' 5 | fi 6 | rm -rf $distro master_temp 7 | wget https://github.com/ShinobiCCTV/Shinobi/tarball/$distro 8 | mkdir master_temp 9 | tar -xzf $distro -C master_temp --strip-components=1 10 | rm -rf camera.js web UPDATE.sh package.json cron.js languages LICENSE COPYING 11 | pm2 stop camera.js 12 | pm2 stop cron.js 13 | pm2 kill 14 | mv master_temp/UPDATE.sh UPDATE.sh 15 | chmod +x UPDATE.sh 16 | sed -i 's/\r//' UPDATE.sh 17 | mv master_temp/languages languages 18 | mv master_temp/definitions definitions 19 | mv master_temp/web web 20 | mv master_temp/LICENSE LICENSE 21 | mv master_temp/COPYING COPYING 22 | mv master_temp/package.json package.json 23 | mv master_temp/camera.js camera.js 24 | mv master_temp/cron.js cron.js 25 | mv master_temp/plugins/motion/shinobi-motion.js plugins/motion/shinobi-motion.js 26 | mv master_temp/plugins/opencv/shinobi-opencv.js plugins/motion/shinobi-opencv.js 27 | npm install 28 | rm -rf $distro master_temp 29 | pm2 start camera.js 30 | pm2 start cron.js 31 | if [ ! -f plugins/motion/conf.json ]; then 32 | pm2 start plugins/motion/shinobi-motion.js 33 | fi -------------------------------------------------------------------------------- /conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 8080, 3 | "addStorage": [ 4 | {"name":"second","path":"__DIR__/videos2"} 5 | ], 6 | "db": { 7 | "host": "127.0.0.1", 8 | "user": "majesticflame", 9 | "password": "", 10 | "database": "ccio", 11 | "port":3306 12 | }, 13 | "mail":{ 14 | "service": "gmail", 15 | "auth": { 16 | "user": "your_email@gmail.com", 17 | "pass": "your_password_or_app_specific_password" 18 | } 19 | }, 20 | "cron":{ 21 | "key":"change_this_to_something_very_random__just_anything_other_than_this" 22 | }, 23 | "pluginKeys":{ 24 | "Motion":"change_this_to_something_very_random____make_sure_to_match__/plugins/motion/conf.json", 25 | "OpenCV":"change_this_to_something_very_random____make_sure_to_match__/plugins/opencv/conf.json", 26 | "OpenALPR":"SomeOpenALPRkeySoPeopleDontMessWithYourShinobi" 27 | } 28 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shinobi", 3 | "version": "1.0.37", 4 | "description": "CCTV and NVR in Node.js, Version : daf882caf6053a7c2c8f4e69427620356f8a440c", 5 | "main": "camera.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "chmod +x INSTALL/start.sh && INSTALL/start.sh" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/moeiscool/Shinobi.git" 13 | }, 14 | "author": "Moe Alam", 15 | "license": "GPLv3", 16 | "bugs": { 17 | "url": "https://github.com/ShinobiCCTV/Shinobi/issues" 18 | }, 19 | "homepage": "https://github.com/moeiscool/Shinobi#readme", 20 | "dependencies": { 21 | "body-parser": "^1.15.2", 22 | "circular-json": "0.3.1", 23 | "connection-tester": "^0.1.1", 24 | "crypto": "^0.0.3", 25 | "mp4frag": "^0.0.15", 26 | "ejs": "^2.5.5", 27 | "express": "^4.14.0", 28 | "jsonfile": "^3.0.1", 29 | "moment": "^2.17.0", 30 | "mysql": "^2.12.0", 31 | "sqlite3": "^3.1.13", 32 | "knex": "^0.14.2", 33 | "ffmpeg-static": "^2.1.0", 34 | "pam-diff": "0.10.2", 35 | "pipe2pam": "0.6.2", 36 | "nodemailer": "^4.0.1", 37 | "onvif": "^0.5.3", 38 | "path": "^0.12.7", 39 | "request": "^2.79.0", 40 | "socket.io": "^1.7.1", 41 | "socket.io-client": "^1.7.2", 42 | "webdav": "^0.3.1", 43 | "ldapauth-fork": "^4.0.2" 44 | }, 45 | "devDependencies": {} 46 | } 47 | -------------------------------------------------------------------------------- /plugins/.gitignore: -------------------------------------------------------------------------------- 1 | opencv-python 2 | ccv 3 | stemkoski 4 | variantai -------------------------------------------------------------------------------- /plugins/child/.gitignore: -------------------------------------------------------------------------------- 1 | conf.json 2 | events 3 | frames -------------------------------------------------------------------------------- /plugins/child/conf.child.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"Macbook", 3 | "ws":"66.51.132.100", 4 | "key":"3123asdasdf1dtj1hjk23sdfaasd12asdasddfdbtnkkfgvesra3asdsd3123afdsfqw345", 5 | } -------------------------------------------------------------------------------- /plugins/child/conf.json.default: -------------------------------------------------------------------------------- 1 | {"host":"127.0.0.1","user":"root","password":"","database":"ccio"} -------------------------------------------------------------------------------- /plugins/microsoft/conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "plug":"ComputerVision", 3 | "host":"localhost", 4 | "port":8080, 5 | "key":"UNIQUE KEY HERE", 6 | "computerVision":{ 7 | "apiKey":"YOUR_KEY", 8 | "endpoint":"http://YOUR_ENDPOINT/analyze", 9 | "params":{ 10 | "visualFeatures": "Categories,Description,Color", 11 | "details": "", 12 | "language": "en" 13 | } 14 | }, 15 | "EmotionAPI":{ 16 | "apiKey":"YOUR_KEY", 17 | "endpoint":"http://YOUR_ENDPOINT/recognize", 18 | "params":{} 19 | }, 20 | "FaceAPI":{ 21 | "apiKey":"YOUR_KEY", 22 | "endpoint":"http://YOUR_ENDPOINT/detect", 23 | "params":{ 24 | "returnFaceId": "true", 25 | "returnFaceLandmarks": "false", 26 | "returnFaceAttributes": "age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise" 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /plugins/microsoft/shinobi-ms-vision.js: -------------------------------------------------------------------------------- 1 | // 2 | // Shinobi - Microsoft Computer Vision Plugin 3 | // Copyright (C) 2016-2025 Moe Alam, moeiscool 4 | // 5 | process.on('uncaughtException', function (err) { 6 | console.error('uncaughtException',err); 7 | }); 8 | var fs=require('fs'); 9 | var exec = require('child_process').exec; 10 | //var http = require('http'); 11 | var request = require('request'); 12 | var moment = require('moment'); 13 | var cognitive = require('cognitive-services'); 14 | var config=require('./conf.json'); 15 | if(config.systemLog===undefined){config.systemLog=true} 16 | s={ 17 | group:{}, 18 | dir:{ 19 | cascades:__dirname+'/cascades/' 20 | }, 21 | isWin:(process.platform==='win32') 22 | } 23 | //default stream folder check 24 | if(!config.streamDir){ 25 | if(s.isWin===false){ 26 | config.streamDir='/dev/shm' 27 | }else{ 28 | config.streamDir=config.windowsTempDir 29 | } 30 | if(!fs.existsSync(config.streamDir)){ 31 | config.streamDir=__dirname+'/streams/' 32 | }else{ 33 | config.streamDir+='/streams/' 34 | } 35 | } 36 | s.dir.streams=config.streamDir; 37 | //streams dir 38 | if(!fs.existsSync(s.dir.streams)){ 39 | fs.mkdirSync(s.dir.streams); 40 | } 41 | s.gid=function(x){ 42 | if(!x){x=10};var t = "";var p = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 43 | for( var i=0; i < x; i++ ) 44 | t += p.charAt(Math.floor(Math.random() * p.length)); 45 | return t; 46 | }; 47 | s.systemLog=function(q,w,e){ 48 | if(!w){w=''} 49 | if(!e){e=''} 50 | if(config.systemLog===true){ 51 | return console.log(moment().format(),q,w,e) 52 | } 53 | } 54 | s.objectToParameter = function(obj){ 55 | return Object.keys(obj).map(function(key) { 56 | return key + '=' + encodeURIComponent(obj[key]); 57 | }).join('&'); 58 | } 59 | s.sendImageToMS=function(sourceImageUrl,API,callback){ 60 | var URL = API.endpoint+'?'+s.objectToParameter(API.params) 61 | request(URL,{ 62 | method: 'POST', 63 | headers:{ 64 | "Ocp-Apim-Subscription-Key":API.apiKey 65 | }, 66 | json: { 67 | url:sourceImageUrl 68 | } 69 | }, callback) 70 | } 71 | s.detectObject=function(buffer,d){ 72 | var sourceImageUrl = 'http://184.105.6.43/'+s.api_key+'/jpeg/'+d.ke+'/'+d.id+'/s.jpg' 73 | // const client = new cognitive.computerVision({ 74 | // apiKey: config.computerVision.apiKey, 75 | // endpoint: config.computerVision.endpoint 76 | // }); 77 | // const parameters = { 78 | // "visualFeatures": "Categories,Tags,Description", 79 | // "details": "Celebrities,Landmarks" 80 | // }; 81 | // const headers = { 82 | // 'Content-type': 'application/json' 83 | // }; 84 | // const body = { 85 | // "url": sourceImageUrl 86 | // }; 87 | // 88 | // client.analyzeImage({ 89 | // parameters, 90 | // headers, 91 | // body 92 | // }).then((response) => { 93 | //// should(response).not.be.undefined(); 94 | //// should(response).have.properties(["categories", "metadata", "requestId"]); 95 | // console.log(response) 96 | // }).catch((err) => { 97 | // console.log('Error',err) 98 | // }); 99 | var responses = {} 100 | s.sendImageToMS(sourceImageUrl,config.computerVision,function(err,resp,body1){ 101 | responses.computerVisionURL = body1 102 | s.sendImageToMS(sourceImageUrl,config.FaceAPI,function(err,resp,body2){ 103 | responses.faceApiURL = body2 104 | s.sendImageToMS(sourceImageUrl,config.EmotionAPI,function(err,resp,body3){ 105 | responses.EmotionAPI = body3 106 | console.log('responses',JSON.stringify(responses,null,3)) 107 | }) 108 | }) 109 | }) 110 | } 111 | s.makeMonitorObject=function(d){ 112 | if(!s.group[d.ke]){ 113 | s.group[d.ke]={} 114 | } 115 | if(!s.group[d.ke][d.id]){ 116 | s.group[d.ke][d.id]={ 117 | port:null, 118 | countStarted:new Date() 119 | } 120 | } 121 | } 122 | io = require('socket.io-client')('ws://'+config.host+':'+config.port);//connect to master 123 | s.cx=function(x){x.pluginKey=config.key;x.plug=config.plug;return io.emit('ocv',x)} 124 | io.on('connect',function(d){ 125 | s.cx({f:'init',plug:config.plug}); 126 | }) 127 | io.on('disconnect',function(d){ 128 | io.connect() 129 | }) 130 | io.on('f',function(d){ 131 | switch(d.f){ 132 | case'api_key': 133 | s.api_key=d.key 134 | break; 135 | case'init_monitor': 136 | if(s.group[d.ke]&&s.group[d.ke][d.id]){ 137 | s.group[d.ke][d.id].buffer=null 138 | s.group[d.ke][d.id].countStarted=new Date() 139 | } 140 | s.makeMonitorObject(d) 141 | break; 142 | case'frame': 143 | d.details={} 144 | try{ 145 | s.makeMonitorObject(d) 146 | if(!s.group[d.ke][d.id].buffer){ 147 | s.group[d.ke][d.id].buffer=[d.frame]; 148 | }else{ 149 | s.group[d.ke][d.id].buffer.push(d.frame) 150 | } 151 | if(d.frame[d.frame.length-2] === 0xFF && d.frame[d.frame.length-1] === 0xD9){ 152 | if(d.mon.detector_frame_save==="1"){ 153 | d.base64=s.group[d.ke][d.id].buffer.toString('base64') 154 | } 155 | if(d.mon.detector_scale_x&&d.mon.detector_scale_x!==''&&d.mon.detector_scale_y&&d.mon.detector_scale_y!==''){ 156 | d.width=d.mon.detector_scale_x; 157 | d.height=d.mon.detector_scale_y; 158 | }else{ 159 | d.width=640 160 | d.height=480 161 | } 162 | s.detectObject(Buffer.concat(s.group[d.ke][d.id].buffer),d) 163 | s.group[d.ke][d.id].buffer=null; 164 | } 165 | } catch(err){ 166 | console.error(err) 167 | } 168 | break; 169 | } 170 | }) -------------------------------------------------------------------------------- /plugins/motion/.gitignore: -------------------------------------------------------------------------------- 1 | conf.json 2 | -------------------------------------------------------------------------------- /plugins/motion/INSTALL.sh: -------------------------------------------------------------------------------- 1 | apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ 2 | npm install canvas 3 | cd plugins/motion 4 | cp conf.sample.json conf.json 5 | pm2 start shinobi-motion.js -------------------------------------------------------------------------------- /plugins/motion/README.md: -------------------------------------------------------------------------------- 1 | # Shinobi Motion Detector 2 | 3 | Install required libraries. 4 | 5 | **Ubuntu and Debian only** 6 | 7 | ``` 8 | sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ 9 | ``` 10 | 11 | **CentOS only** 12 | 13 | ``` 14 | su -c 'yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel' 15 | yum search arial 16 | yum install liberation-sans-fonts.noarch 17 | ``` 18 | 19 | **Install the Node.js Canvas engine** 20 | 21 | ``` 22 | sudo npm install canvas 23 | ``` 24 | 25 | Go to the Shinobi directory. **Below is an example.** 26 | 27 | ``` 28 | cd /home/Shinobi 29 | ``` 30 | 31 | Copy the config file. 32 | 33 | ``` 34 | cp plugins/motion/conf.sample.json plugins/motion/conf.json 35 | ``` 36 | 37 | Edit it the new file. Host should be `localhost` and port should match the `listening port for camera.js`. 38 | 39 | ``` 40 | nano plugins/motion/conf.json 41 | ``` 42 | 43 | Start the plugin. 44 | 45 | ``` 46 | node plugins/motion/shinobi-motion.js 47 | ``` 48 | 49 | Or to daemonize with PM2. 50 | 51 | ``` 52 | pm2 start plugins/motion/shinobi-motion.js 53 | ``` 54 | 55 | Doing this will reveal options in the monitor configuration. Shinobi does not need to be restarted when a plugin is initiated or stopped. 56 | 57 | -------------------------------------------------------------------------------- /plugins/motion/conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "plug":"Motion", 3 | "host":"localhost", 4 | "port":8080, 5 | "key":"change_this_to_something_very_random____make_sure_to_match__/plugins/motion/conf.json", 6 | "notice":"Looks like you have the Motion plugin running. Don't forget to enable Send Frames to start pushing frames to be read." 7 | } -------------------------------------------------------------------------------- /plugins/motion/libs/clusterPoints.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | 5 | data: getterSetter([], function(arrayOfArrays) { 6 | var n = arrayOfArrays[0].length; 7 | return (arrayOfArrays.map(function(array) { 8 | return array.length == n; 9 | }).reduce(function(boolA, boolB) { return (boolA & boolB) }, true)); 10 | }), 11 | 12 | clusters: function() { 13 | var pointsAndCentroids = kmeans(this.data(), {k: this.k(), iterations: this.iterations() }); 14 | var points = pointsAndCentroids.points; 15 | var centroids = pointsAndCentroids.centroids; 16 | 17 | return centroids.map(function(centroid) { 18 | return { 19 | centroid: centroid.location(), 20 | points: points.filter(function(point) { return point.label() == centroid.label() }).map(function(point) { return point.location() }), 21 | }; 22 | }); 23 | }, 24 | 25 | k: getterSetter(undefined, function(value) { return ((value % 1 == 0) & (value > 0)) }), 26 | 27 | iterations: getterSetter(Math.pow(10, 3), function(value) { return ((value % 1 == 0) & (value > 0)) }), 28 | 29 | }; 30 | 31 | function kmeans(data, config) { 32 | // default k 33 | var k = config.k || Math.round(Math.sqrt(data.length / 2)); 34 | var iterations = config.iterations; 35 | 36 | // initialize point objects with data 37 | var points = data.map(function(vector) { return new Point(vector) }); 38 | 39 | // intialize centroids randomly 40 | var centroids = []; 41 | for (var i = 0; i < k; i++) { 42 | centroids.push(new Centroid(points[i % points.length].location(), i)); 43 | }; 44 | 45 | // update labels and centroid locations until convergence 46 | for (var iter = 0; iter < iterations; iter++) { 47 | points.forEach(function(point) { point.updateLabel(centroids) }); 48 | centroids.forEach(function(centroid) { centroid.updateLocation(points) }); 49 | }; 50 | 51 | // return points and centroids 52 | return { 53 | points: points, 54 | centroids: centroids 55 | }; 56 | 57 | }; 58 | 59 | // objects 60 | function Point(location) { 61 | var self = this; 62 | this.location = getterSetter(location); 63 | this.label = getterSetter(); 64 | this.updateLabel = function(centroids) { 65 | var distancesSquared = centroids.map(function(centroid) { 66 | return sumOfSquareDiffs(self.location(), centroid.location()); 67 | }); 68 | self.label(mindex(distancesSquared)); 69 | }; 70 | }; 71 | 72 | function Centroid(initialLocation, label) { 73 | var self = this; 74 | this.location = getterSetter(initialLocation); 75 | this.label = getterSetter(label); 76 | this.updateLocation = function(points) { 77 | var pointsWithThisCentroid = points.filter(function(point) { return point.label() == self.label() }); 78 | if (pointsWithThisCentroid.length > 0) self.location(averageLocation(pointsWithThisCentroid)); 79 | }; 80 | }; 81 | 82 | // convenience functions 83 | function getterSetter(initialValue, validator) { 84 | var thingToGetSet = initialValue; 85 | var isValid = validator || function(val) { return true }; 86 | return function(newValue) { 87 | if (typeof newValue === 'undefined') return thingToGetSet; 88 | if (isValid(newValue)) thingToGetSet = newValue; 89 | }; 90 | }; 91 | 92 | function sumOfSquareDiffs(oneVector, anotherVector) { 93 | var squareDiffs = oneVector.map(function(component, i) { 94 | return Math.pow(component - anotherVector[i], 2); 95 | }); 96 | return squareDiffs.reduce(function(a, b) { return a + b }, 0); 97 | }; 98 | 99 | function mindex(array) { 100 | var min = array.reduce(function(a, b) { 101 | return Math.min(a, b); 102 | }); 103 | return array.indexOf(min); 104 | }; 105 | 106 | function sumVectors(a, b) { 107 | return a.map(function(val, i) { return val + b[i] }); 108 | }; 109 | 110 | function averageLocation(points) { 111 | var zeroVector = points[0].location().map(function() { return 0 }); 112 | var locations = points.map(function(point) { return point.location() }); 113 | var vectorSum = locations.reduce(function(a, b) { return sumVectors(a, b) }, zeroVector); 114 | return vectorSum.map(function(val) { return val / points.length }); 115 | }; 116 | -------------------------------------------------------------------------------- /plugins/openalpr/.gitignore: -------------------------------------------------------------------------------- 1 | conf.json 2 | cascades -------------------------------------------------------------------------------- /plugins/openalpr/README.md: -------------------------------------------------------------------------------- 1 | # OpenALPR and Motion Detector 2 | 3 | Install required libraries. 4 | 5 | **Ubuntu and Debian only** 6 | 7 | ``` 8 | sudo apt update && sudo apt install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ openalpr openalpr-daemon openalpr-utils libopenalpr-dev -y 9 | ``` 10 | 11 | **Install the Node.js Canvas engine** 12 | 13 | ``` 14 | sudo npm install canvas@1.6 15 | ``` 16 | Go to the Shinobi directory. **Below is an example.** 17 | 18 | ``` 19 | cd /home/Shinobi 20 | ``` 21 | 22 | Copy the config file. 23 | 24 | ``` 25 | cp plugins/openalpr/conf.sample.json plugins/openalpr/conf.json 26 | ``` 27 | 28 | Edit it the new file. Host should be `localhost` and port should match the `listening port for camera.js`. 29 | 30 | ``` 31 | nano plugins/openalpr/conf.json 32 | ``` 33 | 34 | Start the plugin. 35 | 36 | ``` 37 | node plugins/openalpr/shinobi-motion.js 38 | ``` 39 | 40 | Or to daemonize with PM2. 41 | 42 | ``` 43 | pm2 start plugins/openalpr/shinobi-motion.js 44 | ``` 45 | 46 | Doing this will reveal options in the monitor configuration. Shinobi does not need to be restarted when a plugin is initiated or stopped. 47 | 48 | ## Run the plugin as a Host 49 | > The main app (Shinobi) will be the client and the plugin will be the host. The purpose of allowing this method is so that you can use one plugin for multiple Shinobi instances. Allowing you to easily manage connections without starting multiple processes. 50 | 51 | Edit your plugins configuration file. Set the `hostPort` **to be different** than the `listening port for camera.js`. 52 | 53 | ``` 54 | nano plugins/openalpr/conf.json 55 | ``` 56 | 57 | Here is a sample of a Host configuration for the plugin. 58 | - `plug` is the name of the plugin corresponding in the main configuration file. 59 | - `https` choose if you want to use SSL or not. Default is `false`. 60 | - `hostPort` can be any available port number. **Don't make this the same port number as Shinobi.** Default is `8082`. 61 | - `type` tells the main application (Shinobi) what kind of plugin it is. In this case it is a detector. 62 | 63 | ``` 64 | { 65 | "plug":"OpenALPR", 66 | "hostPort":8082, 67 | "key":"SomeOpenALPRkeySoPeopleDontMessWithYourShinobi", 68 | "mode":"host", 69 | "type":"detector" 70 | } 71 | ``` 72 | 73 | Now modify the **main configuration file** located in the main directory of Shinobi. *Where you currently should be.* 74 | 75 | ``` 76 | nano conf.json 77 | ``` 78 | 79 | Add the `plugins` array if you don't already have it. Add the following *object inside the array*. 80 | 81 | ``` 82 | "plugins":[ 83 | { 84 | "id" : "OpenALPR", 85 | "https" : false, 86 | "host" : "localhost", 87 | "port" : 8082, 88 | "key" : "SomeOpenALPRkeySoPeopleDontMessWithYourShinobi", 89 | "mode" : "host", 90 | "type" : "detector" 91 | } 92 | ], 93 | ``` -------------------------------------------------------------------------------- /plugins/openalpr/conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "plug":"OpenALPR", 3 | "host":"localhost", 4 | "port":8080, 5 | "hostPort":8082, 6 | "key":"SomeOpenALPRkeySoPeopleDontMessWithYourShinobi", 7 | "mode":"client", 8 | "type":"detector" 9 | } -------------------------------------------------------------------------------- /plugins/openalpr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shinobi-openalpr", 3 | "version": "1.0.0", 4 | "description": "OpenALPR plugin for Shinobi", 5 | "main": "shinobi-openalpr.js", 6 | "dependencies": { 7 | "canvas": "^1.6.7", 8 | "express": "^4.16.2", 9 | "moment": "^2.19.2", 10 | "socket.io": "^2.0.4" 11 | }, 12 | "devDependencies": {}, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "author": "Moe Alam", 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /plugins/opencv/.gitignore: -------------------------------------------------------------------------------- 1 | conf.json 2 | cascades -------------------------------------------------------------------------------- /plugins/opencv/conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "plug":"OpenCV", 3 | "host":"localhost", 4 | "port":8080, 5 | "key":"change_this_to_something_very_random____make_sure_to_match__/plugins/opencv/conf.json" 6 | } -------------------------------------------------------------------------------- /sql/.gitignore: -------------------------------------------------------------------------------- 1 | monitors.sql 2 | users.sql 3 | shinobi.sqlite -------------------------------------------------------------------------------- /sql/database.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.58 3 | -- Server version: 5.7.17-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | 13 | -- Dumping database structure for ccio 14 | CREATE DATABASE IF NOT EXISTS `ccio` /*!40100 DEFAULT CHARACTER SET utf8 */; 15 | USE `ccio`; 16 | 17 | -- Data exporting was unselected. 18 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 19 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 20 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -------------------------------------------------------------------------------- /sql/default_data.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 66.51.132.100 3 | -- Server version: 5.7.16-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | -- Dumping data for table ccio.Users: ~0 rows (approximately) 13 | /*!40000 ALTER TABLE `Users` DISABLE KEYS */; 14 | INSERT INTO `Users` (`ke`, `uid`, `auth`, `mail`, `pass`, `details`) VALUES 15 | ('2Df5hBE', 'XDf5hB3', 'ec49f05c1ddc7d818c61b3343c98cbc6', 'ccio@m03.ca', '5f4dcc3b5aa765d61d8327deb882cf99', '{"days":"10"}'); 16 | INSERT INTO `Monitors` (`mid`, `ke`, `name`, `shto`, `shfr`, `details`, `type`, `ext`, `protocol`, `host`, `path`, `port`, `fps`, `mode`, `width`, `height`) VALUES ('Demo', '2Df5hBE', 'Demo', '[]', '[]', '{"fatal_max":"","notes":"","dir":"","rtsp_transport":"tcp","muser":"","mpass":"","port_force":"0","sfps":"","aduration":"1000000","probesize":"1000000","accelerator":"0","hwaccel":null,"hwaccel_vcodec":"","hwaccel_device":"","stream_type":"hls","stream_mjpeg_clients":"","stream_vcodec":"copy","stream_acodec":"no","hls_time":"","preset_stream":"","hls_list_size":"","signal_check":"","signal_check_log":null,"stream_quality":"","stream_fps":"1","stream_scale_x":"","stream_scale_y":"","rotate_stream":null,"svf":"","stream_timestamp":"0","stream_timestamp_font":"","stream_timestamp_font_size":"","stream_timestamp_color":"","stream_timestamp_box_color":"","stream_timestamp_x":"","stream_timestamp_y":"","stream_watermark":"0","stream_watermark_location":"","stream_watermark_position":null,"snap":"1","snap_fps":"","snap_scale_x":"","snap_scale_y":"","snap_vf":"","vcodec":"copy","crf":"","preset_record":"","acodec":"libvorbis","dqf":null,"cutoff":"10","rotate_record":null,"vf":"","timestamp":"1","timestamp_font":"","timestamp_font_size":"","timestamp_color":"","timestamp_box_color":"","timestamp_x":"","timestamp_y":"","watermark":null,"watermark_location":"","watermark_position":null,"cust_input":"","cust_snap":"","cust_detect":"","cust_stream":"","cust_stream_server":"","cust_record":"","custom_output":"","detector":"0","detector_webhook":null,"detector_webhook_url":"","detector_command_enable":null,"detector_command":"","detector_command_timeout":"","detector_lock_timeout":"","detector_save":null,"detector_frame_save":null,"detector_mail":null,"detector_mail_timeout":"","detector_record_method":null,"detector_trigger":null,"detector_trigger_record_fps":"","detector_timeout":"","watchdog_reset":null,"detector_delete_motionless_videos":null,"detector_send_frames":null,"detector_fps":"","detector_scale_x":"","detector_scale_y":"","detector_use_motion":null,"detector_use_detect_object":null,"detector_frame":null,"detector_sensitivity":"","cords":"","detector_lisence_plate":null,"detector_lisence_plate_country":null,"detector_notrigger":null,"detector_notrigger_mail":null,"detector_notrigger_timeout":"","control":"0","control_base_url":"","control_stop":null,"control_url_stop_timeout":"","control_url_center":"","control_url_left":"","control_url_left_stop":"","control_url_right":"","control_url_right_stop":"","control_url_up":"","control_url_up_stop":"","control_url_down":"","control_url_down_stop":"","control_url_enable_nv":"","control_url_disable_nv":"","control_url_zoom_out":"","control_url_zoom_out_stop":"","control_url_zoom_in":"","control_url_zoom_in_stop":"","groups":"","loglevel":"warning","sqllog":"0","detector_cascades":""}', 'mjpeg', 'mp4', 'http', 'came3.nkansai.ne.jp', '/nphMotionJpeg?Resolution=640x480&Quality=Motion', 81, 15, 'start', 640, 480); 17 | /*!40000 ALTER TABLE `Users` ENABLE KEYS */; 18 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 19 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 20 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 21 | -------------------------------------------------------------------------------- /sql/docker/01-framework.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.58 3 | -- Server version: 5.7.17-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | 13 | -- Dumping structure for table ccio.API 14 | CREATE TABLE IF NOT EXISTS `API` ( 15 | `ke` varchar(50) DEFAULT NULL, 16 | `uid` varchar(50) DEFAULT NULL, 17 | `ip` tinytext, 18 | `code` varchar(100) DEFAULT NULL, 19 | `details` text, 20 | `time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 22 | 23 | -- Data exporting was unselected. 24 | 25 | 26 | -- Dumping structure for table ccio.Events 27 | CREATE TABLE IF NOT EXISTS `Events` ( 28 | `ke` varchar(50) DEFAULT NULL, 29 | `mid` varchar(50) DEFAULT NULL, 30 | `details` text, 31 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 32 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; 33 | 34 | -- Data exporting was unselected. 35 | 36 | 37 | -- Dumping structure for table ccio.Logs 38 | CREATE TABLE IF NOT EXISTS `Logs` ( 39 | `ke` varchar(50) DEFAULT NULL, 40 | `mid` varchar(50) DEFAULT NULL, 41 | `info` text, 42 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 43 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 44 | 45 | -- Data exporting was unselected. 46 | 47 | 48 | -- Dumping structure for table ccio.Monitors 49 | CREATE TABLE IF NOT EXISTS `Monitors` ( 50 | `mid` varchar(50) DEFAULT NULL, 51 | `ke` varchar(50) DEFAULT NULL, 52 | `name` varchar(50) DEFAULT NULL, 53 | `shto` text, 54 | `shfr` text, 55 | `details` longtext, 56 | `type` varchar(50) DEFAULT 'jpeg', 57 | `ext` varchar(50) DEFAULT 'webm', 58 | `protocol` varchar(50) DEFAULT 'http', 59 | `host` varchar(100) DEFAULT '0.0.0.0', 60 | `path` varchar(100) DEFAULT '/', 61 | `port` int(8) DEFAULT '80', 62 | `fps` int(8) DEFAULT '1', 63 | `mode` varchar(15) DEFAULT NULL, 64 | `width` int(11) DEFAULT '640', 65 | `height` int(11) DEFAULT '360' 66 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 67 | 68 | -- Data exporting was unselected. 69 | 70 | 71 | -- Dumping structure for table ccio.Presets 72 | CREATE TABLE IF NOT EXISTS `Presets` ( 73 | `ke` varchar(50) DEFAULT NULL, 74 | `name` text, 75 | `details` text, 76 | `type` enum('monitor','event','user') DEFAULT NULL 77 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 78 | 79 | -- Data exporting was unselected. 80 | 81 | 82 | -- Dumping structure for table ccio.Users 83 | CREATE TABLE IF NOT EXISTS `Users` ( 84 | `ke` varchar(50) DEFAULT NULL, 85 | `uid` varchar(50) DEFAULT NULL, 86 | `auth` varchar(50) DEFAULT NULL, 87 | `mail` varchar(100) DEFAULT NULL, 88 | `pass` varchar(100) DEFAULT NULL, 89 | `details` longtext, 90 | UNIQUE KEY `mail` (`mail`) 91 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 92 | 93 | -- Data exporting was unselected. 94 | 95 | 96 | -- Dumping structure for table ccio.Videos 97 | CREATE TABLE IF NOT EXISTS `Videos` ( 98 | `mid` varchar(50) DEFAULT NULL, 99 | `ke` varchar(50) DEFAULT NULL, 100 | `ext` enum('webm','mp4') DEFAULT NULL, 101 | `time` timestamp NULL DEFAULT NULL, 102 | `duration` float DEFAULT NULL, 103 | `size` float DEFAULT NULL, 104 | `frames` int(11) DEFAULT NULL, 105 | `end` timestamp NULL DEFAULT NULL, 106 | `status` int(1) DEFAULT '0' COMMENT '0:Building,1:Complete,2:Read,3:Archive', 107 | `details` text 108 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 109 | 110 | -- Data exporting was unselected. 111 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 112 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 113 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 114 | -------------------------------------------------------------------------------- /sql/framework.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.37 3 | -- Server version: 10.1.25-MariaDB- - Ubuntu 17.04 4 | -- Server OS: debian-linux-gnu 5 | -- HeidiSQL Version: 9.4.0.5125 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8 */; 10 | /*!50503 SET NAMES utf8mb4 */; 11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 13 | 14 | 15 | -- Dumping database structure for ccio 16 | CREATE DATABASE IF NOT EXISTS `ccio` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; 17 | USE `ccio`; 18 | 19 | -- Dumping structure for table ccio.API 20 | CREATE TABLE IF NOT EXISTS `API` ( 21 | `ke` varchar(50) DEFAULT NULL, 22 | `uid` varchar(50) DEFAULT NULL, 23 | `ip` tinytext, 24 | `code` varchar(100) DEFAULT NULL, 25 | `details` text, 26 | `time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 27 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 28 | 29 | -- Data exporting was unselected. 30 | -- Dumping structure for table ccio.Events 31 | CREATE TABLE IF NOT EXISTS `Events` ( 32 | `ke` varchar(50) DEFAULT NULL, 33 | `mid` varchar(50) DEFAULT NULL, 34 | `details` text, 35 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; 37 | 38 | -- Data exporting was unselected. 39 | -- Dumping structure for table ccio.Logs 40 | CREATE TABLE IF NOT EXISTS `Logs` ( 41 | `ke` varchar(50) DEFAULT NULL, 42 | `mid` varchar(50) DEFAULT NULL, 43 | `info` text, 44 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 45 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 46 | 47 | -- Data exporting was unselected. 48 | -- Dumping structure for table ccio.Monitors 49 | CREATE TABLE IF NOT EXISTS `Monitors` ( 50 | `mid` varchar(50) DEFAULT NULL, 51 | `ke` varchar(50) DEFAULT NULL, 52 | `name` varchar(50) DEFAULT NULL, 53 | `shto` text, 54 | `shfr` text, 55 | `details` longtext, 56 | `type` varchar(50) DEFAULT 'jpeg', 57 | `ext` varchar(50) DEFAULT 'webm', 58 | `protocol` varchar(50) DEFAULT 'http', 59 | `host` varchar(100) DEFAULT '0.0.0.0', 60 | `path` varchar(100) DEFAULT '/', 61 | `port` int(8) DEFAULT '80', 62 | `fps` int(8) DEFAULT '1', 63 | `mode` varchar(15) DEFAULT NULL, 64 | `width` int(11) DEFAULT '640', 65 | `height` int(11) DEFAULT '360' 66 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 67 | 68 | -- Data exporting was unselected. 69 | -- Dumping structure for table ccio.Presets 70 | CREATE TABLE IF NOT EXISTS `Presets` ( 71 | `ke` varchar(50) DEFAULT NULL, 72 | `name` text, 73 | `details` text, 74 | `type` enum('monitor','event','user') DEFAULT NULL 75 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 76 | 77 | -- Data exporting was unselected. 78 | -- Dumping structure for table ccio.Users 79 | CREATE TABLE IF NOT EXISTS `Users` ( 80 | `ke` varchar(50) DEFAULT NULL, 81 | `uid` varchar(50) DEFAULT NULL, 82 | `auth` varchar(50) DEFAULT NULL, 83 | `mail` varchar(100) DEFAULT NULL, 84 | `pass` varchar(100) DEFAULT NULL, 85 | `details` longtext, 86 | UNIQUE KEY `mail` (`mail`) 87 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 88 | 89 | -- Data exporting was unselected. 90 | -- Dumping structure for table ccio.Videos 91 | CREATE TABLE IF NOT EXISTS `Videos` ( 92 | `mid` varchar(50) DEFAULT NULL, 93 | `ke` varchar(50) DEFAULT NULL, 94 | `ext` enum('webm','mp4') DEFAULT NULL, 95 | `time` timestamp NULL DEFAULT NULL, 96 | `duration` float DEFAULT NULL, 97 | `size` float DEFAULT NULL, 98 | `frames` int(11) DEFAULT NULL, 99 | `end` timestamp NULL DEFAULT NULL, 100 | `status` int(1) DEFAULT '0' COMMENT '0:Building,1:Complete,2:Read,3:Archive', 101 | `details` text 102 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 103 | 104 | -- Data exporting was unselected. 105 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 106 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 107 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 108 | -------------------------------------------------------------------------------- /sql/mssql/default_data.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 66.51.132.100 3 | -- Server version: 5.7.16-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | -- Dumping data for table ccio.Users: ~0 rows (approximately) 13 | /*!40000 ALTER TABLE `Users` DISABLE KEYS */; 14 | INSERT INTO Users ([ke], [uid], [auth], [mail], [pass], [details]) VALUES 15 | ('2Df5hBE', 'XDf5hB3', 'ec49f05c1ddc7d818c61b3343c98cbc6', 'ccio@m03.ca', '5f4dcc3b5aa765d61d8327deb882cf99', '{"days":"10"}'); 16 | INSERT INTO Monitors ([mid], [ke], [name], [shto], [shfr], [details], [type], [ext], [protocol], [host], [path], [port], [fps], [mode], [width], [height]) VALUES ('bunny', '2Df5hBE', 'Bunny', '[]', '[]', '{"fatal_max":"","notes":"","dir":"","rtsp_transport":"tcp","muser":"","mpass":"","port_force":"0","sfps":"","aduration":"1000000","probesize":"1000000","accelerator":"0","hwaccel":null,"hwaccel_vcodec":"","hwaccel_device":"","stream_type":"hls","stream_mjpeg_clients":"","stream_vcodec":"copy","stream_acodec":"no","hls_time":"","preset_stream":"","hls_list_size":"","signal_check":"","signal_check_log":null,"stream_quality":"","stream_fps":"1","stream_scale_x":"","stream_scale_y":"","rotate_stream":null,"svf":"","stream_timestamp":"0","stream_timestamp_font":"","stream_timestamp_font_size":"","stream_timestamp_color":"","stream_timestamp_box_color":"","stream_timestamp_x":"","stream_timestamp_y":"","stream_watermark":"0","stream_watermark_location":"","stream_watermark_position":null,"snap":"1","snap_fps":"","snap_scale_x":"","snap_scale_y":"","snap_vf":"","vcodec":"copy","crf":"","preset_record":"","acodec":"libvorbis","dqf":null,"cutoff":"10","rotate_record":null,"vf":"","timestamp":"1","timestamp_font":"","timestamp_font_size":"","timestamp_color":"","timestamp_box_color":"","timestamp_x":"","timestamp_y":"","watermark":null,"watermark_location":"","watermark_position":null,"cust_input":"","cust_snap":"","cust_detect":"","cust_stream":"","cust_stream_server":"","cust_record":"","custom_output":"","detector":"0","detector_webhook":null,"detector_webhook_url":"","detector_command_enable":null,"detector_command":"","detector_command_timeout":"","detector_lock_timeout":"","detector_save":null,"detector_frame_save":null,"detector_mail":null,"detector_mail_timeout":"","detector_record_method":null,"detector_trigger":null,"detector_trigger_record_fps":"","detector_timeout":"","watchdog_reset":null,"detector_delete_motionless_videos":null,"detector_send_frames":null,"detector_fps":"","detector_scale_x":"","detector_scale_y":"","detector_use_motion":null,"detector_use_detect_object":null,"detector_frame":null,"detector_sensitivity":"","cords":"","detector_lisence_plate":null,"detector_lisence_plate_country":null,"detector_notrigger":null,"detector_notrigger_mail":null,"detector_notrigger_timeout":"","control":"0","control_base_url":"","control_stop":null,"control_url_stop_timeout":"","control_url_center":"","control_url_left":"","control_url_left_stop":"","control_url_right":"","control_url_right_stop":"","control_url_up":"","control_url_up_stop":"","control_url_down":"","control_url_down_stop":"","control_url_enable_nv":"","control_url_disable_nv":"","control_url_zoom_out":"","control_url_zoom_out_stop":"","control_url_zoom_in":"","control_url_zoom_in_stop":"","groups":"","loglevel":"warning","sqllog":"0","detector_cascades":""}', 'mjpeg', 'mp4', 'http', 'came3.nkansai.ne.jp', '/nphMotionJpeg?Resolution=640x480&Quality=Motion', 81, 15, 'start', 640, 480); 17 | /*!40000 ALTER TABLE `Users` ENABLE KEYS */; 18 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 19 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 20 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 21 | -------------------------------------------------------------------------------- /sql/mssql/framework.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.37 3 | -- Server version: 10.1.25-MariaDB- - Ubuntu 17.04 4 | -- Server OS: debian-linux-gnu 5 | -- HeidiSQL Version: 9.4.0.5125 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8 */; 10 | /*!50503 SET NAMES utf8mb4 */; 11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 13 | 14 | 15 | -- Dumping database structure for ccio 16 | CREATE DATABASE `ccio` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; 17 | USE ccio; 18 | 19 | -- Dumping structure for table ccio.API 20 | CREATE TABLE API ( 21 | ke varchar(50) DEFAULT NULL, 22 | uid varchar(50) DEFAULT NULL, 23 | ip varchar(255), 24 | code varchar(100) DEFAULT NULL, 25 | details varchar(max), 26 | time datetime2(0) NULL DEFAULT GETDATE() 27 | ) ; 28 | 29 | -- Data exporting was unselected. 30 | -- Dumping structure for table ccio.Events 31 | CREATE TABLE Events ( 32 | ke varchar(50) DEFAULT NULL, 33 | mid varchar(50) DEFAULT NULL, 34 | details varchar(max), 35 | time datetime2(0) NOT NULL DEFAULT GETDATE() 36 | ) ; 37 | 38 | -- Data exporting was unselected. 39 | -- Dumping structure for table ccio.Logs 40 | CREATE TABLE Logs ( 41 | ke varchar(50) DEFAULT NULL, 42 | mid varchar(50) DEFAULT NULL, 43 | info varchar(max), 44 | time datetime2(0) NOT NULL DEFAULT GETDATE() 45 | ) ; 46 | 47 | -- Data exporting was unselected. 48 | -- Dumping structure for table ccio.Monitors 49 | CREATE TABLE Monitors ( 50 | mid varchar(50) DEFAULT NULL, 51 | ke varchar(50) DEFAULT NULL, 52 | name varchar(50) DEFAULT NULL, 53 | shto varchar(max), 54 | shfr varchar(max), 55 | details varchar(max), 56 | type varchar(50) DEFAULT 'jpeg', 57 | ext varchar(50) DEFAULT 'webm', 58 | protocol varchar(50) DEFAULT 'http', 59 | host varchar(100) DEFAULT '0.0.0.0', 60 | path varchar(100) DEFAULT '/', 61 | port int DEFAULT '80', 62 | fps int DEFAULT '1', 63 | mode varchar(15) DEFAULT NULL, 64 | width int DEFAULT '640', 65 | height int DEFAULT '360' 66 | ) ; 67 | 68 | -- Data exporting was unselected. 69 | -- Dumping structure for table ccio.Presets 70 | CREATE TABLE Presets ( 71 | ke varchar(50) DEFAULT NULL, 72 | name varchar(max), 73 | details varchar(max), 74 | type enum('monitor','event','user') DEFAULT NULL 75 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 76 | 77 | -- Data exporting was unselected. 78 | -- Dumping structure for table ccio.Users 79 | CREATE TABLE Users ( 80 | ke varchar(50) DEFAULT NULL, 81 | uid varchar(50) DEFAULT NULL, 82 | auth varchar(50) DEFAULT NULL, 83 | mail varchar(100) DEFAULT NULL, 84 | pass varchar(100) DEFAULT NULL, 85 | details varchar(max), 86 | CONSTRAINT mail UNIQUE (mail) 87 | ) ; 88 | 89 | -- Data exporting was unselected. 90 | -- Dumping structure for table ccio.Videos 91 | CREATE TABLE Videos ( 92 | mid varchar(50) DEFAULT NULL, 93 | ke varchar(50) DEFAULT NULL, 94 | ext enum('webm','mp4') DEFAULT NULL, 95 | time datetime2(0) NULL DEFAULT NULL, 96 | duration float DEFAULT NULL, 97 | size float DEFAULT NULL, 98 | frames int DEFAULT NULL, 99 | end datetime2(0) NULL DEFAULT NULL, 100 | status int DEFAULT '0' , 101 | details varchar(max) 102 | ) ; 103 | 104 | -- Data exporting was unselected. 105 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 106 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 107 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 108 | -------------------------------------------------------------------------------- /sql/mssql/user.sql: -------------------------------------------------------------------------------- 1 | CREATE USER 'majesticflame'@'127.0.0.1' IDENTIFIED BY ''; 2 | GRANT ALL PRIVILEGES ON ccio.* TO 'majesticflame'@'127.0.0.1'; 3 | FLUSH PRIVILEGES; -------------------------------------------------------------------------------- /sql/postgresql/default_data.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 66.51.132.100 3 | -- Server version: 5.7.16-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | -- Dumping data for table ccio.Users: ~0 rows (approximately) 13 | /*!40000 ALTER TABLE `Users` DISABLE KEYS */; 14 | INSERT INTO Users (ke, uid, auth, mail, pass, details) VALUES 15 | ('2Df5hBE', 'XDf5hB3', 'ec49f05c1ddc7d818c61b3343c98cbc6', 'ccio@m03.ca', '5f4dcc3b5aa765d61d8327deb882cf99', '{"days":"10"}'); 16 | INSERT INTO Monitors (mid, ke, name, shto, shfr, details, type, ext, protocol, host, path, port, fps, mode, width, height) VALUES ('bunny', '2Df5hBE', 'Bunny', '[]', '[]', '{"fatal_max":"","notes":"","dir":"","rtsp_transport":"tcp","muser":"","mpass":"","port_force":"0","sfps":"","aduration":"1000000","probesize":"1000000","accelerator":"0","hwaccel":null,"hwaccel_vcodec":"","hwaccel_device":"","stream_type":"hls","stream_mjpeg_clients":"","stream_vcodec":"copy","stream_acodec":"no","hls_time":"","preset_stream":"","hls_list_size":"","signal_check":"","signal_check_log":null,"stream_quality":"","stream_fps":"1","stream_scale_x":"","stream_scale_y":"","rotate_stream":null,"svf":"","stream_timestamp":"0","stream_timestamp_font":"","stream_timestamp_font_size":"","stream_timestamp_color":"","stream_timestamp_box_color":"","stream_timestamp_x":"","stream_timestamp_y":"","stream_watermark":"0","stream_watermark_location":"","stream_watermark_position":null,"snap":"1","snap_fps":"","snap_scale_x":"","snap_scale_y":"","snap_vf":"","vcodec":"copy","crf":"","preset_record":"","acodec":"libvorbis","dqf":null,"cutoff":"10","rotate_record":null,"vf":"","timestamp":"1","timestamp_font":"","timestamp_font_size":"","timestamp_color":"","timestamp_box_color":"","timestamp_x":"","timestamp_y":"","watermark":null,"watermark_location":"","watermark_position":null,"cust_input":"","cust_snap":"","cust_detect":"","cust_stream":"","cust_stream_server":"","cust_record":"","custom_output":"","detector":"0","detector_webhook":null,"detector_webhook_url":"","detector_command_enable":null,"detector_command":"","detector_command_timeout":"","detector_lock_timeout":"","detector_save":null,"detector_frame_save":null,"detector_mail":null,"detector_mail_timeout":"","detector_record_method":null,"detector_trigger":null,"detector_trigger_record_fps":"","detector_timeout":"","watchdog_reset":null,"detector_delete_motionless_videos":null,"detector_send_frames":null,"detector_fps":"","detector_scale_x":"","detector_scale_y":"","detector_use_motion":null,"detector_use_detect_object":null,"detector_frame":null,"detector_sensitivity":"","cords":"","detector_lisence_plate":null,"detector_lisence_plate_country":null,"detector_notrigger":null,"detector_notrigger_mail":null,"detector_notrigger_timeout":"","control":"0","control_base_url":"","control_stop":null,"control_url_stop_timeout":"","control_url_center":"","control_url_left":"","control_url_left_stop":"","control_url_right":"","control_url_right_stop":"","control_url_up":"","control_url_up_stop":"","control_url_down":"","control_url_down_stop":"","control_url_enable_nv":"","control_url_disable_nv":"","control_url_zoom_out":"","control_url_zoom_out_stop":"","control_url_zoom_in":"","control_url_zoom_in_stop":"","groups":"","loglevel":"warning","sqllog":"0","detector_cascades":""}', 'mjpeg', 'mp4', 'http', 'came3.nkansai.ne.jp', '/nphMotionJpeg?Resolution=640x480&Quality=Motion', 81, 15, 'start', 640, 480); 17 | /*!40000 ALTER TABLE `Users` ENABLE KEYS */; 18 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 19 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 20 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 21 | -------------------------------------------------------------------------------- /sql/postgresql/framework.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.37 3 | -- Server version: 10.1.25-MariaDB- - Ubuntu 17.04 4 | -- Server OS: debian-linux-gnu 5 | -- HeidiSQL Version: 9.4.0.5125 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8 */; 10 | /*!50503 SET NAMES utf8mb4 */; 11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 13 | 14 | 15 | -- Dumping database structure for ccio 16 | CREATE DATABASE `ccio` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; 17 | USE ccio; 18 | 19 | -- Dumping structure for table ccio.API 20 | CREATE TABLE IF NOT EXISTS API ( 21 | ke varchar(50) DEFAULT NULL, 22 | uid varchar(50) DEFAULT NULL, 23 | ip tinytext, 24 | code varchar(100) DEFAULT NULL, 25 | details text, 26 | time timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP 27 | ) ; 28 | 29 | -- Data exporting was unselected. 30 | -- Dumping structure for table ccio.Events 31 | CREATE TABLE IF NOT EXISTS Events ( 32 | ke varchar(50) DEFAULT NULL, 33 | mid varchar(50) DEFAULT NULL, 34 | details text, 35 | time timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP 36 | ) ; 37 | 38 | -- Data exporting was unselected. 39 | -- Dumping structure for table ccio.Logs 40 | CREATE TABLE IF NOT EXISTS Logs ( 41 | ke varchar(50) DEFAULT NULL, 42 | mid varchar(50) DEFAULT NULL, 43 | info text, 44 | time timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP 45 | ) ; 46 | 47 | -- Data exporting was unselected. 48 | -- Dumping structure for table ccio.Monitors 49 | CREATE TABLE IF NOT EXISTS Monitors ( 50 | mid varchar(50) DEFAULT NULL, 51 | ke varchar(50) DEFAULT NULL, 52 | name varchar(50) DEFAULT NULL, 53 | shto text, 54 | shfr text, 55 | details longtext, 56 | type varchar(50) DEFAULT 'jpeg', 57 | ext varchar(50) DEFAULT 'webm', 58 | protocol varchar(50) DEFAULT 'http', 59 | host varchar(100) DEFAULT '0.0.0.0', 60 | path varchar(100) DEFAULT '/', 61 | port int DEFAULT '80', 62 | fps int DEFAULT '1', 63 | mode varchar(15) DEFAULT NULL, 64 | width int DEFAULT '640', 65 | height int DEFAULT '360' 66 | ) ; 67 | 68 | -- Data exporting was unselected. 69 | -- Dumping structure for table ccio.Presets 70 | CREATE TABLE IF NOT EXISTS Presets ( 71 | ke varchar(50) DEFAULT NULL, 72 | name text, 73 | details text, 74 | type enum('monitor','event','user') DEFAULT NULL 75 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 76 | 77 | -- Data exporting was unselected. 78 | -- Dumping structure for table ccio.Users 79 | CREATE TABLE IF NOT EXISTS Users ( 80 | ke varchar(50) DEFAULT NULL, 81 | uid varchar(50) DEFAULT NULL, 82 | auth varchar(50) DEFAULT NULL, 83 | mail varchar(100) DEFAULT NULL, 84 | pass varchar(100) DEFAULT NULL, 85 | details longtext, 86 | CONSTRAINT mail UNIQUE (mail) 87 | ) ; 88 | 89 | -- Data exporting was unselected. 90 | -- Dumping structure for table ccio.Videos 91 | CREATE TABLE IF NOT EXISTS Videos ( 92 | mid varchar(50) DEFAULT NULL, 93 | ke varchar(50) DEFAULT NULL, 94 | ext enum('webm','mp4') DEFAULT NULL, 95 | time timestamp(0) NULL DEFAULT NULL, 96 | duration double precision DEFAULT NULL, 97 | size double precision DEFAULT NULL, 98 | frames int DEFAULT NULL, 99 | end timestamp(0) NULL DEFAULT NULL, 100 | status int DEFAULT '0' , 101 | details text 102 | ) ; 103 | 104 | -- Data exporting was unselected. 105 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 106 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 107 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 108 | -------------------------------------------------------------------------------- /sql/postgresql/user.sql: -------------------------------------------------------------------------------- 1 | CREATE USER 'majesticflame'@'127.0.0.1' IDENTIFIED BY ''; 2 | GRANT ALL PRIVILEGES ON ccio.* TO 'majesticflame'@'127.0.0.1'; 3 | FLUSH PRIVILEGES; -------------------------------------------------------------------------------- /sql/shinobi.sample.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moeiscool/Shinobi/2600e91ff79290f0e3203f154356018f4f1846d2/sql/shinobi.sample.sqlite -------------------------------------------------------------------------------- /sql/sqlite3/framework.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.16 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) 2 | -- 3 | -- Host: localhost Database: db 4 | -- ------------------------------------------------------ 5 | -- Server version 10.1.26-MariaDB-0+deb9u1 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8mb4 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 18 | 19 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 20 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 21 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 22 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 23 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 24 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 25 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 26 | 27 | -- Dump completed on 2018-02-11 20:25:54 28 | -------------------------------------------------------------------------------- /sql/sqllog.txt: -------------------------------------------------------------------------------- 1 | update-5-6-2017.sql - allows Idle mode options and future proofs the mode field for other modes. -------------------------------------------------------------------------------- /sql/tables.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.58 3 | -- Server version: 5.7.17-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | 13 | 14 | -- Dumping structure for table ccio.API 15 | CREATE TABLE IF NOT EXISTS `API` ( 16 | `ke` varchar(50) DEFAULT NULL, 17 | `uid` varchar(50) DEFAULT NULL, 18 | `ip` tinytext, 19 | `code` varchar(100) DEFAULT NULL, 20 | `details` text, 21 | `time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 23 | 24 | -- Data exporting was unselected. 25 | 26 | 27 | -- Dumping structure for table ccio.Events 28 | CREATE TABLE IF NOT EXISTS `Events` ( 29 | `ke` varchar(50) DEFAULT NULL, 30 | `mid` varchar(50) DEFAULT NULL, 31 | `details` text, 32 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; 34 | 35 | -- Data exporting was unselected. 36 | 37 | 38 | -- Dumping structure for table ccio.Logs 39 | CREATE TABLE IF NOT EXISTS `Logs` ( 40 | `ke` varchar(50) DEFAULT NULL, 41 | `mid` varchar(50) DEFAULT NULL, 42 | `info` text, 43 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 44 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 45 | 46 | -- Data exporting was unselected. 47 | 48 | 49 | -- Dumping structure for table ccio.Monitors 50 | CREATE TABLE IF NOT EXISTS `Monitors` ( 51 | `mid` varchar(50) DEFAULT NULL, 52 | `ke` varchar(50) DEFAULT NULL, 53 | `name` varchar(50) DEFAULT NULL, 54 | `shto` text, 55 | `shfr` text, 56 | `details` longtext, 57 | `type` varchar(50) DEFAULT 'jpeg', 58 | `ext` varchar(50) DEFAULT 'webm', 59 | `protocol` varchar(50) DEFAULT 'http', 60 | `host` varchar(100) DEFAULT '0.0.0.0', 61 | `path` varchar(100) DEFAULT '/', 62 | `port` int(8) DEFAULT '80', 63 | `fps` int(8) DEFAULT '1', 64 | `mode` varchar(15) DEFAULT NULL, 65 | `width` int(11) DEFAULT '640', 66 | `height` int(11) DEFAULT '360' 67 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 68 | 69 | -- Data exporting was unselected. 70 | 71 | 72 | -- Dumping structure for table ccio.Presets 73 | CREATE TABLE IF NOT EXISTS `Presets` ( 74 | `ke` varchar(50) DEFAULT NULL, 75 | `name` text, 76 | `details` text, 77 | `type` enum('monitor','event','user') DEFAULT NULL 78 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 79 | 80 | -- Data exporting was unselected. 81 | 82 | 83 | -- Dumping structure for table ccio.Users 84 | CREATE TABLE IF NOT EXISTS `Users` ( 85 | `ke` varchar(50) DEFAULT NULL, 86 | `uid` varchar(50) DEFAULT NULL, 87 | `auth` varchar(50) DEFAULT NULL, 88 | `mail` varchar(100) DEFAULT NULL, 89 | `pass` varchar(100) DEFAULT NULL, 90 | `details` longtext, 91 | UNIQUE KEY `mail` (`mail`) 92 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 93 | 94 | -- Data exporting was unselected. 95 | 96 | 97 | -- Dumping structure for table ccio.Videos 98 | CREATE TABLE IF NOT EXISTS `Videos` ( 99 | `mid` varchar(50) DEFAULT NULL, 100 | `ke` varchar(50) DEFAULT NULL, 101 | `ext` enum('webm','mp4') DEFAULT NULL, 102 | `time` timestamp NULL DEFAULT NULL, 103 | `duration` float DEFAULT NULL, 104 | `size` float DEFAULT NULL, 105 | `frames` int(11) DEFAULT NULL, 106 | `end` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 107 | `status` int(1) DEFAULT '0' COMMENT '0:Open,1:Complete,2:Error,3:Unknown' 108 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 109 | 110 | -- Data exporting was unselected. 111 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 112 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 113 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -------------------------------------------------------------------------------- /sql/update-1-1-2017.sql: -------------------------------------------------------------------------------- 1 | USE ccio; 2 | ALTER TABLE Monitors MODIFY ext VARCHAR(50); 3 | 4 | CREATE TABLE IF NOT EXISTS `API` ( 5 | `ke` varchar(50) DEFAULT NULL, 6 | `uid` varchar(50) DEFAULT NULL, 7 | `ip` tinytext, 8 | `code` varchar(100) DEFAULT NULL, 9 | `details` text, 10 | `time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /sql/update-13-7-2017.sql: -------------------------------------------------------------------------------- 1 | USE `ccio`; 2 | ALTER TABLE Videos CHANGE end end TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; -------------------------------------------------------------------------------- /sql/update-17-5-2017.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `ccio`; 2 | USE `ccio`; 3 | 4 | CREATE TABLE IF NOT EXISTS `BackupVideos` ( 5 | `mid` varchar(50) DEFAULT NULL, 6 | `ke` varchar(50) DEFAULT NULL, 7 | `ext` varchar(15) DEFAULT NULL, 8 | `time` timestamp NULL DEFAULT NULL, 9 | `end` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 10 | `size` float DEFAULT NULL, 11 | `details` longtext 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 13 | 14 | ALTER TABLE Videos MODIFY COLUMN `ext` varchar(15); 15 | ALTER TABLE Videos ADD `details` longtext; 16 | ALTER TABLE Videos DROP COLUMN `frames`; 17 | ALTER TABLE Videos DROP COLUMN `duration`; -------------------------------------------------------------------------------- /sql/update-2-2-2017.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 192.168.88.58 3 | -- Server version: 5.7.17-0ubuntu0.16.04.1 - (Ubuntu) 4 | -- Server OS: Linux 5 | -- HeidiSQL Version: 9.3.0.4984 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8mb4 */; 10 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 11 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 12 | 13 | -- Dumping database structure for ccio 14 | USE ccio; 15 | ALTER TABLE `Monitors` CHANGE COLUMN `protocol` `protocol` VARCHAR(50) NULL DEFAULT 'http' AFTER `ext`; 16 | 17 | -- Dumping structure for table ccio.Events 18 | CREATE TABLE IF NOT EXISTS `Events` ( 19 | `ke` varchar(50) DEFAULT NULL, 20 | `mid` varchar(50) DEFAULT NULL, 21 | `details` text, 22 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; 24 | 25 | -- Data exporting was unselected. 26 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 27 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 28 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 29 | -------------------------------------------------------------------------------- /sql/update-26-08-2017.sql: -------------------------------------------------------------------------------- 1 | use ccio 2 | ALTER TABLE `Videos` ADD COLUMN `details` TEXT NULL DEFAULT NULL AFTER `status`; -------------------------------------------------------------------------------- /sql/update-5-6-2017.sql: -------------------------------------------------------------------------------- 1 | USE `ccio`; 2 | 3 | ALTER TABLE Monitors MODIFY COLUMN `mode` varchar(15); -------------------------------------------------------------------------------- /sql/user.sql: -------------------------------------------------------------------------------- 1 | CREATE USER 'majesticflame'@'127.0.0.1' IDENTIFIED BY ''; 2 | GRANT ALL PRIVILEGES ON ccio.* TO 'majesticflame'@'127.0.0.1'; 3 | FLUSH PRIVILEGES; -------------------------------------------------------------------------------- /super.sample.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "mail":"admin@shinobi.video", 4 | "pass":"21232f297a57a5a743894a0e4a801fc3" 5 | } 6 | ] -------------------------------------------------------------------------------- /tools/addVideos.js.disabled: -------------------------------------------------------------------------------- 1 | //add videos to SQL tables from filesystem 2 | var fs = require('fs'); 3 | var moment = require('moment'); 4 | var mysql = require('mysql'); 5 | var config = require('../conf.json'); 6 | s={} 7 | s.disc=function(){ 8 | sql = mysql.createConnection(config.db); 9 | sql.connect(function(err){if(err){console.log('Error Connecting : DB',err);setTimeout(s.disc, 2000);}}); 10 | sql.on('error',function(err) {console.log('DB Lost.. Retrying..');console.log(err);s.disc();return;}); 11 | } 12 | s.disc(); 13 | if(!config.videosDir){config.videosDir=__dirname+'/../videos/'} 14 | s.dir={videos:config.videosDir}; 15 | s.nameToTime=function(x){x=x.split('.')[0].split('T'),x[1]=x[1].replace(/-/g,':');x=x.join(' ');return x;} 16 | s.moment=function(e,x){ 17 | if(!e){e=new Date};if(!x){x='YYYY-MM-DDTHH-mm-ss'}; 18 | return moment(e).format(x); 19 | } 20 | fs.readdir(s.dir.videos,function(err,groups){ 21 | groups.forEach(function(group){ 22 | fs.readdir(s.dir.videos+group,function(err,cameras){ 23 | cameras.forEach(function(camera){ 24 | fs.readdir(s.dir.videos+group+'/'+camera,function(err,videos){ 25 | sql.query('SELECT * FROM Videos WHERE ke=? AND mid=?',[group,camera],function(err,r){ 26 | videos.forEach(function(filename){ 27 | fs.stat(s.dir.videos+group+'/'+camera+'/'+filename,function(err,file){ 28 | file.startTime=s.nameToTime(filename) 29 | file.endTime=s.moment(file.mtime,'YYYY-MM-DD HH:mm:ss') 30 | var save=[camera,group,filename.split('.')[1],file.size,file.startTime,file.endTime,1] 31 | var found=null 32 | r.forEach(function(v){ 33 | if(s.moment(v.time,'YYYY-MM-DD HH:mm:ss')===file.startTime){ 34 | found=v 35 | } 36 | }) 37 | if(!found){ 38 | console.log('!found',save) 39 | sql.query('INSERT INTO Videos (mid,ke,ext,size,time,end,status) VALUES (?,?,?,?,?,?,?)',save) 40 | } 41 | }) 42 | }) 43 | }) 44 | }) 45 | }) 46 | }) 47 | }) 48 | }) -------------------------------------------------------------------------------- /tools/translateLanguageFile.js: -------------------------------------------------------------------------------- 1 | console.log('This translation tool uses Yandex.') 2 | if(!process.argv[2]||!process.argv[3]||!process.argv[4]){ 3 | console.log('You must input arguments.') 4 | console.log('# node translateLanguageFile.js