Kyle Hall
e97b099d58
If I run a query like "SELECT NOW()" from a koha report, I will get a different answer than if I had run it from koha-mysql. In Koha, we set the timezone for each database connection. However, koha-mysql does not do this, so instead we are left using the default timezone of the database. Test Plan: 1) Set your time zone to something other than the database time zone 2) run "SELECT NOW()" using debian/scripts/koha-mysql *not* /usr/sbin/koha-mysql 3) Note you get the database timezone's current time 4) Apply this patch 5) Repeat step 2 6) Now you get the correct time! Signed-off-by: Michal Urban <michalurban177@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
67 lines
2.3 KiB
Bash
Executable file
67 lines
2.3 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# koha-mysql: provide an interactive mysql shell set up for the specified
|
|
# koha instance.
|
|
# Copyright 2011 Catalyst IT, Ltd
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
umask 0077
|
|
|
|
# include helper functions
|
|
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
|
|
. "/usr/share/koha/bin/koha-functions.sh"
|
|
else
|
|
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
usage()
|
|
{
|
|
local scriptname=$0
|
|
cat <<EOF
|
|
Run mysql in the context of a given Koha instance.
|
|
|
|
Usage: $scriptname instancename [ optional mysql arguments ]
|
|
|
|
EOF
|
|
}
|
|
|
|
# Parse command line.
|
|
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
|
|
|
|
name="$1"
|
|
|
|
is_instance "$name" || ( usage; die "Unknown instance '$name'" )
|
|
|
|
shift # remove instance name from argument list.
|
|
kohaconfig="/etc/koha/sites/$name/koha-conf.xml"
|
|
|
|
mysqlhost="$( xmlstarlet sel -t -v 'yazgfs/config/hostname' $kohaconfig )" || die "hostname missing from $kohaconfig"
|
|
mysqldb="$( xmlstarlet sel -t -v 'yazgfs/config/database' $kohaconfig )" || die "database missing from $kohaconfig"
|
|
mysqluser="$( xmlstarlet sel -t -v 'yazgfs/config/user' $kohaconfig )" || die "user missing from $kohaconfig"
|
|
mysqlpass="$( xmlstarlet sel -t -v 'yazgfs/config/pass' $kohaconfig )" || die "pass missing from $kohaconfig"
|
|
|
|
mysqltz="$( xmlstarlet sel -t -v 'yazgfs/config/timezone' $kohaconfig )"
|
|
if [ $? -eq 0 ]
|
|
then
|
|
echo "Using time zone $mysqltz"
|
|
mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" --init-command="SET time_zone = '$mysqltz'" \
|
|
"$mysqldb" "${@}"
|
|
else
|
|
echo "No time zone set for Koha, using database time zone."
|
|
mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \
|
|
"$mysqldb" "${@}"
|
|
fi
|
|
|