From b45bba779bead4855011b0ed2faf150ca47b5282 Mon Sep 17 00:00:00 2001 From: Andreas Jonsson Date: Thu, 4 Jul 2019 16:44:34 +0200 Subject: [PATCH] Bug 23141: Parse mysql portnumber from /etc/mysql/koha-common.cnf --- debian/scripts/koha-create | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 6d5ffa0e8d..b670610c56 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -137,6 +137,22 @@ getmysqlhost() { /etc/mysql/koha-common.cnf } +getmysqlport() { + if [ -e /etc/mysql/koha-common.cnf ] + then + port=$(awk ' + BEGIN { FS="=" } + $1 ~/\[/ { inclient=0 } + $1 ~/\[client\]/ { inclient=1; next } + inclient==1 && $1 ~/port/ { gsub(/ /, "", $2); print $2 }' \ + /etc/mysql/koha-common.cnf) + else + port=3306 + fi + + echo $port +} + getinstancemysqlpassword() { xmlstarlet sel -t -v 'yazgfs/config/pass' "/etc/koha/sites/$1/koha-conf.xml" } @@ -597,6 +613,11 @@ then mysqlhost="$(getmysqlhost)" fi +if [ "$mysqlport" = "" ] +then + mysqlport="$(getmysqlport)" +fi + if [ "$op" = create ] || [ "$op" = request ] || [ "$op" = use ] then if [ "$mysqlpwd" = "" ] @@ -685,7 +706,7 @@ eof touch "$name-db-request.txt" chmod 0600 "$name-db-request.txt" cat > "$name-db-request.txt" << eof -Please create a MySQL database and user on $mysqlhost as follows: +Please create a MySQL database and user on $mysqlhost port $mysqlport as follows: database name: $mysqldb database user: $mysqluser -- 2.20.1