Bug 18564

Summary: koha-common.cnf parsing is too restrictive
Product: Koha Reporter: Eric Vantillard <eric.vantillard>
Component: Installation and upgrade (command-line installer)Assignee: Eric Vantillard <eric.vantillard>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: chris, jonathan.druart, m.de.rooy, mtompset, nick
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9409
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: patch changing the awk script
Bug 18564: MariaDB doesn't have a debian.cnf file
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host

Description Eric Vantillard 2017-05-09 19:09:18 UTC
my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in koha-conf.xml containing no values in hostname element.

as a result trying to connect to the web serveur will raise an error :

Software error:

DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1490. at /usr/share/koha/lib/Koha/Database.pm line 90
Compilation failed in require at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 31.
BEGIN failed--compilation aborted at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 31.
For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.
Comment 1 Eric Vantillard 2017-05-09 19:20:05 UTC
adding spaces around the equal sign will resolve the issue

the problem is in kohl-create function getmysqlhost()

https://github.com/Koha-Community/Koha/blob/master/debian/scripts/koha-create#L124

the awk search require spaces
Comment 2 Eric Vantillard 2017-05-09 20:04:10 UTC
maybe something like that

awk '
BEGIN {
	FS="="
}
$1 ~/\[/ {
	inclient=0
}
$1 ~/\[client\]/ {
	inclient=1
	next
}
inclient==1 && $1 ~/host/ {
	print $2
}
' /etc/mysql/koha-common.cnf
Comment 3 Eric Vantillard 2017-05-17 15:18:42 UTC
Created attachment 63501 [details] [review]
patch changing the awk script
Comment 4 Mark Tompsett 2017-06-22 22:32:31 UTC
Is this patch ready to sign off?
I have an amendment to make. :)
Comment 5 Mark Tompsett 2017-06-22 22:49:14 UTC
Created attachment 64557 [details] [review]
Bug 18564: MariaDB doesn't have a debian.cnf file

The koha-common.cnf file is a link to debian.cnf, which MariaDB
does not install. This just forces a 'localhost' return value.
Comment 6 Jonathan Druart 2017-09-26 17:39:25 UTC
(In reply to M. Tompsett from comment #5)
> Created attachment 64557 [details] [review] [review]
> Bug 18564: MariaDB doesn't have a debian.cnf file
> 
> The koha-common.cnf file is a link to debian.cnf, which MariaDB
> does not install. This just forces a 'localhost' return value.

Please move it to its own bug report.
Comment 7 Jonathan Druart 2017-09-26 17:41:15 UTC
Created attachment 67371 [details] [review]
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host

my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in
koha-conf.xml containing no values in hostname element.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Marcel de Rooy 2017-10-20 09:49:00 UTC
Created attachment 68315 [details] [review]
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host

my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in
koha-conf.xml containing no values in hostname element.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2017-10-20 09:50:17 UTC
Thanks, Eric'.
Looks good to me, improving my awk skills on the way..
Comment 10 Jonathan Druart 2017-10-20 20:15:00 UTC
Patch pushed to master for 17.11.

Thanks and congrats Éric it is your first patch in!