From a494755a15afa04a421eab440aa0eee7dca31352 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 5 Dec 2018 18:26:40 +0100 Subject: [PATCH] flush_query_cache.sh: fix error if mysql distribution is not MySQL (i.e. Percona/MariaDB). --- flush_query_cache.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/flush_query_cache.sh b/flush_query_cache.sh index b9fcacc..29198d9 100755 --- a/flush_query_cache.sh +++ b/flush_query_cache.sh @@ -28,16 +28,30 @@ MYSQL_MAJOR_VERSION=`echo $CURRENT_VERSION | cut -d '.' -f1` MYSQL_MINOR_VERSION=`echo $CURRENT_VERSION | cut -d '.' -f2` MYSQL_PATCH_LEVEL=`echo $CURRENT_VERSION | cut -d '.' -f3` -if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ - || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ - || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ - && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then +if [[ -z "$_MYSQLD_VERSION" ]]; then echo "" - echo -e "\t[ Error ]: Query cache is no longer supported since (MySQL 8.0.3)" + echo -e "\t[ Error ]: No installed MySQL server or distribution found!" echo "" +elif [[ "$_MYSQLD_VERSION" =~ MariaDB ]]; then + MYSQL_CUR_DISTRIBUTION="MariaDB" +elif [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ percona- ]]; then + MYSQL_CUR_DISTRIBUTION="Percona" +elif [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mysql- ]]; then + MYSQL_CUR_DISTRIBUTION="MySQL" +fi + +if [[ "$MYSQL_CUR_DISTRIBUTION" = "MySQL" ]]; then + if [[ "$MYSQL_MAJOR_VERSION" -gt 8 ]] \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -gt 0 ]] ) \ + || ( [[ "$MYSQL_MAJOR_VERSION" -eq 8 ]] && [[ "$MYSQL_MINOR_VERSION" -eq 0 ]] \ + && [[ $MYSQL_PATCH_LEVEL -ge 3 ]] ); then + echo "" + echo -e "\t[ Error ]: Query cache is no longer supported since (MySQL 8.0.3)" + echo "" + exit + fi fi -exit #---------------------------------------