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>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Eric Vantillard 2017-05-09 23:10:21 +02:00 committed by Jonathan Druart
parent 850243ee2e
commit 7ed705ea45
1 changed files with 4 additions and 3 deletions

View File

@ -124,9 +124,10 @@ generate_config_file() {
getmysqlhost() {
awk '
/^\[/ { inclient = 0 }
/^\[client\]/ { inclient = 1 }
inclient && /^ *host *=/ { print $3 }' \
BEGIN { FS="=" }
$1 ~/\[/ { inclient=0 }
$1 ~/\[client\]/ { inclient=1; next }
inclient==1 && $1 ~/host/ { gsub(/ /, "", $2); print $2 }' \
/etc/mysql/koha-common.cnf
}