SHINOBI: Instalación ubuntu server 18.04

  • Actualizamos el sistema:
apt update && apt upgrade && apt dist-upgrade -y

MariaBD

  • Instalamos:
apt -y install software-properties-common
  • Instalamos
apt install gnupg
  • Agregamos las llaves gpg
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.liquidtelecom.com/repo/10.4/ubuntu bionic main'
  • Actualizamos
apt update
  • Mandamos a instalar
apt install mariadb-server mariadb-client -y
  • Mandamos a configurar
mysql_secure_installation
  • RESULTADO
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] 
New password: 
Re-enter new password: 
Sorry, passwords do not match.
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] 
 ... Success!
Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

NODE JS

  • Instalamos
apt install nodejs npm -y
  • Verificamos la versión
nodejs --version

Shinobi

  • Instalamos
apt install ffmpeg2theora libvpx-dev x264 git sudo software-properties-common net-tools make unzip zip ffmpeg-doc ffmpeg -y
  • Ingresamos a
cd ~
  • Clonamos el repositorio
git clone https://gitlab.com/Shinobi-Systems/Shinobi.git Shinobi
  • Ingresamos al directorio
cd Shinobi
  • Instalamos
chmod +x INSTALL/ubuntu.sh && INSTALL/ubuntu.sh
  • Inicia la instalación
=========================================================
==!! Shinobi : The Open Source CCTV and NVR Solution !!==
=========================================================
To answer yes type the letter (y) in lowercase and press ENTER.
Default is no (N). Skip any components you already have or don't need.
=============
=============
 Detecting Ubuntu Version
=============
=============
 Ubuntu Version: 10
=============
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
wget ya está en su versión más reciente (1.20.1-1.1).
Se instalarán los siguientes paquetes NUEVOS:
  sudo
0 actualizados, 1 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Se necesita descargar 1 245 kB de archivos.
Se utilizarán 3 886 kB de espacio de disco adicional después de esta operación.
Des:1 http://deb.debian.org/debian buster/main amd64 sudo amd64 1.8.27-1 [1 245 kB]
Descargados 1 245 kB en 1s (1 374 kB/s)
Seleccionando el paquete sudo previamente no seleccionado.
(Leyendo la base de datos ... 44789 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../sudo_1.8.27-1_amd64.deb ...
Desempaquetando sudo (1.8.27-1) ...
Configurando sudo (1.8.27-1) ...
Procesando disparadores para man-db (2.8.5-2) ...
Procesando disparadores para systemd (241-7~deb10u1) ...
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
software-properties-common ya está en su versión más reciente (0.96.20.2-2).
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Error: 'universe' invalid
=============
Default Superuser : admin@shinobi.video
Default Password : admin
* You can edit these settings in "super.json" located in the Shinobi directory.
=============
Shinobi - Installing Net-Tools
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
Se instalarán los siguientes paquetes NUEVOS:
  net-tools
0 actualizados, 1 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Se necesita descargar 248 kB de archivos.
Se utilizarán 1 002 kB de espacio de disco adicional después de esta operación.
Des:1 http://deb.debian.org/debian buster/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1 [248 kB]
Descargados 248 kB en 1s (455 kB/s) 
Seleccionando el paquete net-tools previamente no seleccionado.
(Leyendo la base de datos ... 44910 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../net-tools_1.60+git20180626.aebd88e-1_amd64.deb ...
Desempaquetando net-tools (1.60+git20180626.aebd88e-1) ...
Configurando net-tools (1.60+git20180626.aebd88e-1) ...
Procesando disparadores para man-db (2.8.5-2) ...
Node.js Found...
Version : v10.15.2
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
make ya está en su versión más reciente (4.2.1-1.2).
fijado make como instalado manualmente.
Se instalarán los siguientes paquetes NUEVOS:
  unzip zip
0 actualizados, 2 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Se necesita descargar 405 kB de archivos.
Se utilizarán 1 202 kB de espacio de disco adicional después de esta operación.
Des:1 http://deb.debian.org/debian buster/main amd64 unzip amd64 6.0-23+deb10u1 [172 kB]
Des:2 http://deb.debian.org/debian buster/main amd64 zip amd64 3.0-11+b1 [234 kB]
Descargados 405 kB en 1s (716 kB/s)
Seleccionando el paquete unzip previamente no seleccionado.
(Leyendo la base de datos ... 44967 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../unzip_6.0-23+deb10u1_amd64.deb ...
Desempaquetando unzip (6.0-23+deb10u1) ...
Seleccionando el paquete zip previamente no seleccionado.
Preparando para desempaquetar .../zip_3.0-11+b1_amd64.deb ...
Desempaquetando zip (3.0-11+b1) ...
Configurando unzip (6.0-23+deb10u1) ...
Configurando zip (3.0-11+b1) ...
Procesando disparadores para man-db (2.8.5-2) ...
Procesando disparadores para mime-support (3.62) ...
INSTALL/ubuntu.sh: línea 57: 16: No existe el fichero o el directorio
=============
Shinobi - Installing FFMPEG
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
Paquetes sugeridos:
  ffmpeg-doc
Se instalarán los siguientes paquetes NUEVOS:
  ffmpeg
0 actualizados, 1 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Se necesita descargar 1 425 kB de archivos.
Se utilizarán 1 998 kB de espacio de disco adicional después de esta operación.
Des:1 http://deb.debian.org/debian buster/main amd64 ffmpeg amd64 7:4.1.4-1~deb10u1 [1 425 kB]
Descargados 1 425 kB en 1s (2 111 kB/s) 
Seleccionando el paquete ffmpeg previamente no seleccionado.
(Leyendo la base de datos ... 45001 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../ffmpeg_7%3a4.1.4-1~deb10u1_amd64.deb ...
Desempaquetando ffmpeg (7:4.1.4-1~deb10u1) ...
Configurando ffmpeg (7:4.1.4-1~deb10u1) ...
Procesando disparadores para man-db (2.8.5-2) ...
=============
Shinobi - Do you want to use MariaDB or SQLite3?
SQLite3 is better for small installs
MariaDB (MySQL) is better for large installs
(S)QLite3 or (M)ariaDB?
Press [ENTER] for default (MariaDB)
M
Shinobi - Do you want to Install MariaDB? Choose No if you already have it.
(y)es or (N)o
n
=============
Shinobi - Database Installation
(y)es or (N)o
y
What is your SQL Username?
root
What is your SQL Password?
HB0
=============
Shinobi - Install NPM Libraries
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.11.3
added 430 packages from 833 contributors in 16.293s
npm WARN deprecated circular-json@0.3.1: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated snekfetch@3.6.4: use node-fetch instead

> dtrace-provider@0.8.8 install /root/Shinobi/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js

make: se entra en el directorio '/root/Shinobi/node_modules/dtrace-provider/build'
  TOUCH Release/obj.target/DTraceProviderStub.stamp
make: se sale del directorio '/root/Shinobi/node_modules/dtrace-provider/build'

> core-js@2.6.9 postinstall /root/Shinobi/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN discord.js@11.5.1 requires a peer of bufferutil@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN shinobi@2.0.0 No license field.

added 486 packages from 464 contributors and audited 1627 packages in 36.413s
found 0 vulnerabilities

npm WARN using --force I sure hope you know what you are doing.
npm WARN discord.js@11.5.1 requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN shinobi@2.0.0 No license field.

up to date in 7.818s
fixed 0 of 0 vulnerabilities in 1627 scanned packages
=============
Shinobi - Install PM2
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ pm2@3.0.0
added 312 packages from 245 contributors in 28.855s
Shinobi - Finished
INSTALL/ubuntu.sh: línea 131: dos2unix: orden no encontrada
Shinobi - Start Shinobi and set to start on boot?
(y)es or (N)o
y
__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /root/Shinobi/camera.js in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ camera   │ 0  │ fork │ 16091 │ online │ 0       │ 0s     │ 0%  │ 21.4 MB   │ root │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
[PM2] Starting /root/Shinobi/cron.js in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ camera   │ 0  │ fork │ 16091 │ online │ 0       │ 1s     │ 0%  │ 47.8 MB   │ root │ disabled │
│ cron     │ 1  │ fork │ 16132 │ online │ 0       │ 0s     │ 0%  │ 8.4 MB    │ root │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/root/.pm2
PIDFile=/root/.pm2/pm2.pid

ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

Target path
/etc/systemd/system/pm2-root.service
Command list

[ 'systemctl enable pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-root...
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-root.service → /etc/systemd/system/pm2-root.service.
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd
[PM2] Saving current process list...
[PM2] Successfully saved in /root/.pm2/dump.pm2
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
│ App name │ id │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
│ camera   │ 0  │ fork │ 16091 │ online │ 0       │ 5s     │ 0%  │ 92.0 MB   │ root │ disabled │
│ cron     │ 1  │ fork │ 16132 │ online │ 0       │ 3s     │ 0%  │ 59.4 MB   │ root │ disabled │
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
=====================================
||=====   Install Completed   =====||
=====================================
|| Login with the Superuser and create a new user!!
||===================================
INSTALL/ubuntu.sh: línea 148: ifconfig: orden no encontrada
|| Open http://:8080/super in your web browser.
||===================================
|| Default Superuser : admin@shinobi.video
|| Default Password : admin
=====================================
=====================================
  • Ahora podemos ingresar el navegador a la dirección
http://10.20.200.157:8080/
  • Con las credenciales
|| Default Superuser : admin@shinobi.video
|| Default Password : admin

MARIABD usuario remoto

  • Abrimos
nano /etc/mysql/my.cnf
  • Buscamos y modificamos
bind-address            = 127.0.0.1
X
#bind-address            = 127.0.0.1
  • Reiniciamos
systemctl restart mariadb.service
  • Ingresamos como usuario root
mysql -u root -p
  • Creamos el usuario
GRANT ALL PRIVILEGES ON *.* TO 'remoto'@'%' IDENTIFIED BY 'RB0' WITH GRANT OPTION;
FLUSH PRIVILEGES;
  • Reiniciamos
systemctl restart mariadb.service

Configuración

  • Ahora ingresamos al navegador a la dirección:
http://10.20.200.161:8080/super
  • Ingresamos con los datos:
|| Default Superuser : admin@shinobi.video
|| Default Password : admin
  • Vamos al tab de «Configuración», para modificar el usuario de bd
  • Modificamos:
"db": {
      "host": "127.0.0.1",
      "user": "remoto",
      "password": "RB0",
      "database": "ccio",
      "port": 3306
   },
  • Reiniciamos el servicio
pm2 restart cron.js

Crear usuario

  • Ingresamos al tab «Accounts»
  • Ingresamos los datos