Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID and Password #4

Closed
kozoke opened this issue Sep 14, 2018 · 11 comments
Closed

ID and Password #4

kozoke opened this issue Sep 14, 2018 · 11 comments

Comments

@kozoke
Copy link

kozoke commented Sep 14, 2018

Hi,
I'm trying to log into the admin account
Web Address : http://xxx.xxx.xxx.xxx:8080/super
Username : admin@shinobi.video
Password : admin

but it won't accept the password. Any suggestions?

@todvndvn
Copy link

todvndvn commented Sep 27, 2018

admin account I figured from the Dockerhub tags, the password is administrator

[https://hub.docker.com/r/migoller/shinobi/~/dockerfile/]

But in the admin interface, I am unable to create any further users.

@MiGoller
Copy link
Owner

Hey guys. I'm sorry for being offline so long.

If you do not set any environment variables running a container based on my Shinobi Docker images you should be able to access the corresponding web UIs:

How to access the different UIs

As far as I know it's not possible to login to the admin UI or the default web UI with the super admin account! I struggled a long time with those issues when I started to set up Shinobi.

So, please add at least a regular admin account to your installation first, right?

If you want to integrate any LDAP accounts, please let me know.

The Super Admin UI

Try to open http://[IP of Docker host]:8080/super in your browser. You'll have to enter the credentials you've set for your Docker container.

Environment variable Dockerfile default value
ADMIN_USER admin@shinobi.video
ADMIN_PASSWORD administrator

After the login succeeded you should get a screen like this.
grafik

Hit "+" on the right side of "Account" to enter a new regular admin account.

The Admin UI

Open http://[IP of Docker host]:8080/admin in your browser. You'll have to login with the credentials of an admin account you've created with the super admin account. If the login succeeds you'll get a screen like this.
grafik
Now you can add additional "regular" user accounts, assign special rights to them, etc. .

The (default) Web UI

Now try to open http://[IP of Docker host]:8080 in your browser, please. You should be able to login with credentials of admin or user accounts.

Here we go ...

Please let me know, if you're able to login now.

@todvndvn : You say

But in the admin interface, I am unable to create any further users.

To which admin interface do you login: Super admin UI or admin UI?

Best Regards,
Michael

@todvndvn
Copy link

@MiGoller , You are awesome. Thanks for the reply.

shinobisuper1

Except for the initial login on IPADDRESS/super URL, nothing is working. Unable to create any users in IPADDRESS/admin page or on the IPADDRESS:PORT page.

Upon further digging I found that mysql did not create database. I logged into the container tried to start mysql and failed. So I uninstalled and reinstalled mysql but it still stuck the same sock error as below.

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Appreciate your inputs.

Thanks.

@MiGoller
Copy link
Owner

Ah, ok. Looks like I have to update the readme files. I'm sorry for that.

I've stripped down the image for micro-services environments; so MySQL or MariaDB are missing at all. The images support existing MySQL oder MariaDB servers. You'll have to set the following environment variables to accomplish that:

  • MYSQL_USER=majesticflame --> Runtime username for accessing Shinobi's database
  • MYSQL_PASSWORD=password --> Sets the password for the runtime user.
  • MYSQL_HOST=db --> Set to the hostname or IP-Addr of your existing MySQL or MariaDB server. Name of linked containers still work, too.
  • MYSQL_DATABASE=ccio --> Sets the name of Shinobi's database
  • MYSQL_ROOT_PASSWORD=[Your secret root password] --> Set to the root password of you MySQL server
  • MYSQL_ROOT_USER=root --> MySQL user with root privileges

If you set these environment variables the container will check upon every start if the database exists. If not, the container will create the database even on a remote host, creates the user account, sets it's password and grants access to the Shinobi database.

So, do you have an existing MySQL or MariaDB server? If not I'll supply instruction on how to set up a dedicated MySQL server on Docker; another way is to run docker stack or compose to create the corresponding containers. I'll provide that szenario within my upcoming commits.

For easier use I'll add another flavour of images with already installed MySQL servers. Would the be helpfull to you?

Regards,
Michael

@MiGoller
Copy link
Owner

Hey all,

thank you for your feedback. I've setup an environment for this issue and I'm able to reproduce a stable workaround as long as none of my images ships with MySQL.

Ok, let's go. Please follow the instructions to get it up and running, hopefully. The following steps will pull my latest Alpine-based Shinobi image and the latest MariaDB image from Docker Hub. I encountered many problems setting up the environment with the latest MySQL image.

Docker-Compose

Install docker-compose if it's not installed.
Just run $ sudo apt-get install docker-compose.

A dedicated directory for the Shinobi instance

Create a directory for this workaround to keep Shinobi's database, configuration files and video files. Let's say we name it shinobi.
$ mkdir shinobi

Change into that freshly created directory.
$ cd shinobi

Now create the the subdirectories for database, configuration files and video files.
$ mkdir c_datadir c_config c_videos

Create the environment files

You will create environment files now for Shinobi and MariaDB settings, so we do not have to pass the environment variables to each container for every variable.

Shinoni.env : Shinobi settings

Create a file named Shinobi.envwith this default content. You would find it inside the Dockerfile if you're interested in.

ADMIN_USER=admin@shinobi.video
ADMIN_PASSWORD=administrator
CRON_KEY=b59b5c62-57d0-4cd1-b068-a55e5222786f
PLUGINKEY_MOTION=49ad732d-1a4f-4931-8ab8-d74ff56dac57
PLUGINKEY_OPENCV=6aa3487d-c613-457e-bba2-1deca10b7f5d
PLUGINKEY_OPENALPR=SomeOpenALPRkeySoPeopleDontMessWithYourShinobi
MOTION_HOST=localhost
MOTION_PORT=8080

MySQL.env : Database settings

Create a file named MySQL.envwith this content. Once again that's nothing special.

MYSQL_USER=majesticflame
MYSQL_PASSWORD=password
MYSQL_HOST=db
MYSQL_DATABASE=ccio
MYSQL_ROOT_PASSWORD=blubsblawoot
MYSQL_ROOT_USER=root

Creating and running a stack of Shinobi web app and MariaDB server

Next we will use docker-compose to create and start a stack for Shinobi with a container for Shinobi and a container for MariaDB.

The docker-compose.yml file

Create a file named docker-compose.yml with this content. The content differs from the last commit to my corresponding GitHub repository, because I switched from MySQL to MariaDB because of connection issues.

version: '2'
services:
  db:
    image: mariadb
    env_file:
      - MySQL.env
    volumes:
      - ./c_datadir:/var/lib/mysql
  web:
    image: migoller/shinobi:alpine
    env_file:
      - MySQL.env
      - Shinobi.env
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./c_config:/config
      - ./c_videos:/opt/shinobi/videos
    depends_on:
      - db
    ports:
      - "8080:8080"

This file instructs docker-compose to create two containers for this stack:

  • A container db for the MariaDB server.
  • A container web for the Shinobi app.

We will persist the data with volume mounts to the directories created earlier.

Create the stack

Ok, now let's see if the stack's containers will be created as expected.
$ docker-compose -f ./docker-compose.yml create

Finally the output should show that the containers have been created. The output must not show errors creating the containers.

Creating shinobi_db_1
Creating shinobi_web_1
$ 

If you have named the directory differently the containers will have different names.

Run the stack

We have successfully created the containers. Now start the stack for the very first time.
$ docker-compose -f ./docker-compose.yml up

The docker-compose command will show you any container output.

Creating network "shinobi_default" with the default driver
Creating shinobi_db_1
Creating shinobi_web_1
Attaching to shinobi_db_1, shinobi_web_1
web_1  | Copy custom configuration files ...
web_1  | No custom config files found.
web_1  | Create default config file /opt/shinobi/conf.json ...
web_1  | Create default config file /opt/shinobi/super.json ...
web_1  | Create default config file /opt/shinobi/plugins/motion/conf.json ...
web_1  | Hash admin password ...
web_1  | Wait for MySQL server ...
web_1  | cp: can't stat '/config/*': No such file or directory
db_1   | Initializing database
db_1   |

The first start will take a few moments because the MariaDB server environment and the Shinobi database have to be set up first.

Look for Shinobi is ready.. If you find it... well Shinobi is up and running.

web_1  | Set MySQL configuration from environment variables ...
web_1  |   . Username
web_1  |   . Password
web_1  |   . Host
web_1  |   . Database
web_1  | Set keys for CRON and PLUGINS from environment variables ...
web_1  | Set configuration for motion plugin from environment variables ...
web_1  | Starting Shinobi ...
web_1  | [2018-09-27 xx:xx:xx] PM2 log: Launching in no daemon mode
web_1  | [2018-09-27 xx:xx:xx] PM2 log: Starting execution sequence in -fork mode- for app name:Camera-App id:0
web_1  | [2018-09-27 xx:xx:xx] PM2 log: Starting execution sequence in -fork mode- for app name:Cron-App id:1
web_1  | [2018-09-27 xx:xx:xx] PM2 log: App name:Camera-App id:0 online
web_1  | [2018-09-27 xx:xx:xx] PM2 log: App name:Cron-App id:1 online
web_1  | [2018-09-27 xx:xx:xx] PM2 log: Starting execution sequence in -fork mode- for app name:Motion-App id:2
web_1  | [2018-09-27 xx:xx:xx] PM2 log: App name:Motion-App id:2 online
web_1  | Shinobi : cron.js started
web_1  | NODE.JS version : v8.10.0
web_1  | FFMPEG version : 3.4.2-static https://johnvansickle.com/ffmpeg/
web_1  | Shinobi - PORT : 8080
web_1  | 2018-09-27T20:05:03+02:00 Critical update 1/2 already applied
web_1  | 2018-09-27T20:05:03+02:00 Critical update 2/2 already applied
web_1  | 2018-09-27T20:05:04+02:00 pluginInitiatorSuccess { f: 'init',
web_1  |   plug: 'Motion',
web_1  |   notice: 'Looks like you have the Motion plugin running. Don\'t forget to enable <b>Send Frames</b> to start pushing frames to be read.',
web_1  |   pluginKey: '49ad732d-1a4f-4931-8ab8-d74ff56dac57' }
web_1  | 2018-09-27Txx:xx:xx+02:00 Connected to plugin : Detector - Motion - undefined
web_1  | 2018-09-27Txx:xx:xx+02:00 admin@local.org : size check for videos : 0
web_1  | 2018-09-27Txx:xx:xx+02:00 admin@local.org : end of size check for videos 1/1
web_1  | 2018-09-27Txx:xx:xx+02:00 all users checked, wait to close open files and remove files over user limit
web_1  | 2018-09-27Txx:xx:xx+02:00 waiting to give unfinished video check some time. 3 seconds.
web_1  | 2018-09-27Txx:xx:xx+02:00 starting all monitors set to watch and record
web_1  | 2018-09-27Txx:xx:xx+02:00 Shinobi is ready.

Login to the web UIs

Now you should be able to login to the super admin dashboard at http://[IP of Docker host]:8080/super. Give it a try, please.

If you're able to login as the super admin with the credentials found in the Shinobi.ebv file, create a normal admin first.

Now login http://[IP of Docker host]:8080/admin with the admin credentials. The super admin will not be able to login. Create a regular user account.

Finally login to the users dashboard http://[IP of Docker host]:8080 with admin or user credentials. The super admin will not be able to login.

Please let me know if you get it up and running.

Regards,
Michael

@todvndvn
Copy link

@MiGoller Oh Boy!! what a guide.. kudos for a great writeup. Its successfully up and running.........

just like that.
☺☺☺
Best regards,

PS: One small suggestion to improve it for noobs like me.. please update sudo in the command line of docker-compose at both places. Without SUDO if we used the command, the error message is not so obvious. That's all.

@MiGoller
Copy link
Owner

You're welcome. I'm happy about you get it up and running successfully. Thank you for your feedback. I'll modify my docs and publish them later. I will close this issue, right?

Btw: Do your run Docker CE on a Linux distro? If so, did you follow the installation on Get Docker CE for Ubuntu? Docker privides Post-installation steps for Linux including a section on how to manage Docker as a non-root user. You'd just have to create a group named docker and add your own useraccount as a member to that group. Logoff and login again.

Regards,
Michael

@lmamakos
Copy link

lmamakos commented Dec 30, 2018

This is very helpful. I think that an older Docker solution for shinobi managed to have the mysql database inside the container, rather than in external volumes on persistent storage. I would really like to be able to re-create the containers to get later versions without having to worry about all that state disappearing.

@MiGoller
Copy link
Owner

MiGoller commented Feb 4, 2019

Hey Imamakos.

I'm sorry for comming back to you so lately. I still provide "official" Docker images for Shinobi including MariaDB server as well. It's up to you. Please have a look at the "offical"-tagged images on https://cloud.docker.com/repository/docker/migoller/shinobidocker/tags .

To persist your data using the "official" images you have to bind or mount the container's data directory /var/lib/mysql like -v [Path to Shinobi direcory]/datadir:/var/lib/mysql .

@MiGoller
Copy link
Owner

MiGoller commented Mar 5, 2019

Hey Imamakos.

I'll close this issue if my hint did the trick to you.

@lmamakos
Copy link

Sure, thanks for the pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants