ONLYOFFICE / Docker-CommunityServer

Collaborative system for managing documents, projects, customer relations and emails in one place
MIT License
471 stars 175 forks source link

Unknown database 'onlyoffice_mailserver' #53

Open Daniel-Beardsmore opened 5 years ago

Daniel-Beardsmore commented 5 years ago

Installation command under Debian 8:

bash opensource-install.sh -md domain --mysqlrootpassword "custom-password" --mysqluser custom-username --mysqlpassword "another-custom-password" --mysqlmailuser another-custom-username --mysqlmailpassword "a-third-custom-password"

Is this an unsupported configuration? Are there limits on the permissible characters in passwords? I was not comfortable with the idea of letting the installation script use a set of simple, publicly-available usernames and passwords.

The whole stack did install, but attempts to work with the mail server fail, and typing "docker container logs onlyoffice-community-server" returns a lot of:

ERROR 1049 (42000): Unknown database 'onlyoffice_mailserver'

Unfortunately the installation appeared to work correctly, and no notification was raised anywhere about failing to create this database. "docker container logs onlyoffice-community-server" does not contain any message about the database not being created.

It seems that there are two problems:

a) We have some kind of circumstance where the onlyoffice_mailserver does not get created b) When the above error occurs, it is buried

opensource-install.sh simply followed the Docker process with "Thank you for installing ONLYOFFICE. In case you have any questions ..." and the in-browser first-run initialisation seemed to complete without error.

Issue 32 covered a situation when the database did not get created, but that was closed in November last year, and I would figure that a fresh installation at this point in time would no longer have that problem. There is a help page "Connecting Mail Server to Community Server on Linux" but this itself assumes that the database already exists.

Daniel-Beardsmore commented 5 years ago

Ah, I see, the mail server container assembles the database by hand. So, under "docker container logs onlyoffice-mail-server":

* * Start iRedMail Configurations * [ INFO ] Create required system accounts: vmail, iredapd. [ INFO ] Configure Apache web server and PHP. [ INFO ] Configure PHP. [ INFO ] Configure MySQL database server. ERROR 1045 (28000): Access denied for user 'root'@'onlyoffice-mail-server.onlyoffice' (using password: YES

(and so on)

However, this works:

docker exec -it onlyoffice-mail-server bash mysql -h $MYSQL_SERVER -u $MYSQL_ROOT_USER --password=$MYSQL_ROOT_PASSWD

So something has failed. The end of the logs for that container shows:

Starting server Traceback (most recent call last): File "/usr/share/spamtrainer/spamtrainer.py", line 5, in import settings File "/usr/share/spamtrainer/settings.py", line 4 DATABASE_PASSWORD = ^ SyntaxError: invalid syntax

In the latter instance, it's like the passwords didn't make it into the setup script somehow, but they had to in order to get "using password: YES" in the former instance. The relevant lines of that file are:

# database settings DATABASE_NAME = 'onlyoffice_mailserver' DATABASE_USER = 'root' DATABASE_PASSWORD = DATABASE_HOST = 'onlyoffice-mysql-server'

Daniel-Beardsmore commented 5 years ago

Note to self: '#' in passwords does not work inside ${MYSQL_DEFAULTS_FILE_ROOT} …

(I had a feeling it was this, but I needed to prove exactly where it went wrong. The answer is mysql_generate_defaults_file_root() inside /usr/src/iRedMail/functions/mysql.sh when it puts the password into a plain text file.)

With regards to the bug, though, it's clear that the installation process is too decentralised and nothing seems to check statuses or collect the errors from downstream tasks, so if an error occurs somewhere during the process, it is just ignored and discarded: iRedMail.sh just blunders on, completely unaware that it has derailed, and the OnlyOffice installer doesn't check up to see whether the container installation succeeded.

Of course, now this is technically also an iRedMail bug ...

andrewborell commented 5 years ago

Note to self: '#' in passwords does not work inside ${MYSQL_DEFAULTS_FILE_ROOT} …

Seems special characters in general are not acceptable, or at least @ is not as well. My observation is the password will cut off wherever you place the first instance of a special character. e.g.) 123@456 would show only 123 in /usr/share/spamtrainer/settings.py