juanluisbaptiste / docker-otrs

The unofficial Znuny/OTRS Ticketing System docker image
https://www.juanbaptiste.tech/category/otrs
GNU Lesser General Public License v3.0
173 stars 101 forks source link

Env OTRS_DB_NAME lost in some point #45

Closed barajas-victor closed 5 years ago

barajas-victor commented 5 years ago

Hello, I have a problem when deploying the image of OTRS 6, the problem is that when I use the variable OTRS_DB_NAME at some point in the execution, its value is lost or maybe it is not being respected. For example if I have OTRS_DB_NAME=otrs3 the container executes all the steps in mysql container and creates the database otrs3 but when OTRS tries to start it tries to connect to the DB otrs and not to otrs3.

I took as a base your Dockerfile file to create my own image and that is what I use for the Stack.

config file

version: "3.2"

services:
  uat-otrs2:
    image: my-image # base your dockerfile
    environment:
    # Default first run
      - OTRS_INSTALL=no
      - OTRS_DROP_DATABASE=yes
    # DB configs
      - OTRS_DB_HOST=uat-mysql2
      - OTRS_DB_PORT=3306
      - OTRS_DB_USER=prueba
      - OTRS_DB_PASSWORD=prueba
      - OTRS_DB_NAME=otrs3
    # MySQL root pass for create de initial DB
      - MYSQL_ROOT_PASSWORD=*****

    # OTRS configs
      - OTRS_ROOT_PASSWORD=OTRSadmin
      - OTRS_LANGUAGE=es
      - OTRS_TIMEZONE=UTC
      - OTRS_NUMBER_GENERATOR=DateChecksum

    # Debug mode
      - OTRS_DEBUG=yes
...
other stuff

logs

| ERROR 1049 (42000) at line 1: Unknown database 'otrs3'
| + '[' 1 -gt 0 ']'
| + create_db
| + print_info 'Creating OTRS database...'
| + echo -e '\e[46m[INFO]\e[0m Creating OTRS database...'
| + mysql -uroot -h uat-mysql2 -P 3306 -p***** -e 'CREATE DATABASE IF NOT EXISTS otrs3;'
| [INFO] Creating OTRS database...
| + '[' 0 -gt 0 ']'
| + mysql -uroot -h uat-mysql2 -P 3306 -p**** -e ' GRANT ALL ON otrs3.* to '\''prueba'\''@'\''%'\'' identified by '\''prueba'\'''
| + '[' 0 -gt 0 ']'
| + '[' no == no ']'
| + print_info 'Loading default db schemas...'
| + echo -e '\e[46m[INFO]\e[0m Loading default db schemas...'
| [INFO] Loading default db schemas...
| + mysql -uroot -h uat-mysql2 -P 3306 -p***** otrs3
| [INFO] Loading initial db inserts...
| + '[' 0 -gt 0 ']'
| + print_info 'Loading initial db inserts...'
| + echo -e '\e[46m[INFO]\e[0m Loading initial db inserts...'
| + mysql -uroot -h uat-mysql2 -P 3306 -p***** otrs3
| [INFO] Loading initial schema constraints...
| + '[' 0 -gt 0 ']'
| + print_info 'Loading initial schema constraints...'
| + echo -e '\e[46m[INFO]\e[0m Loading initial schema constraints...'
| + mysql -uroot -h uat-mysql2 -P 3306 -p***** otrs3
| + '[' 0 -gt 0 ']'
| + print_info 'Setting password for default admin account \e[38;5;31mroot@localhost\e[0m to: \e[31mOTRSadmin\e[0m'
| [INFO] Setting password for default admin account root@localhost to: OTRSadmin
| + echo -e '\e[46m[INFO]\e[0m Setting password for default admin account \e[38;5;31mroot@localhost\e[0m to: \e[31mOTRSadmin\e[0m'
| + su -c '/opt/otrs/bin/otrs.Console.pl Admin::User::SetPassword root@localhost OTRSadmin' -s /bin/bash otrs
| [Mon Nov  5 22:41:47 2018] otrs.Console.pl: DBI connect('database=otrs;host=uat-mysql2;','prueba',...) failed: Access denied for user 'prueba'@'%' to database 'otrs' at /opt/otrs/Kernel/System/DB.pm line 204.
| ERROR: OTRS-otrs.Console.pl-Admin::User::SetPassword-10 Perl: 5.16.3 OS: linux Time: Mon Nov  5 22:41:47 2018
|
|  Message: Access denied for user 'prueba'@'%' to database 'otrs'

From what I can notice instead of using the otrs3 database some part of the script tries to useotrs.

DB

With the defined user prueba and password prueba

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| otrs3              |
+--------------------+
juanluisbaptiste commented 5 years ago

Fixed. Reopen if you still have issues.