second run: determin 'MYSQL_CREDENTIAL_ARGS' if not given.
This commit is contained in:
@@ -159,6 +159,29 @@ trim() {
|
||||
echo -n "$var"
|
||||
}
|
||||
|
||||
detect_mysql_version () {
|
||||
|
||||
_MYSQLD_VERSION="$(mysqld -V 2>/dev/null)"
|
||||
|
||||
if [[ -z "$_MYSQLD_VERSION" ]]; then
|
||||
fatal "No installed MySQL server or distribution found!"
|
||||
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
|
||||
|
||||
MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)"
|
||||
MYSQL_MAJOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1)"
|
||||
MYSQL_MINOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f2)"
|
||||
MYSQL_PATCH_LEVEL="$(echo $MYSQL_VERSION | cut -d '.' -f3)"
|
||||
MYSQL_MAIN_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1,2)"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
trap clean_up SIGHUP SIGINT SIGTERM
|
||||
@@ -238,7 +261,42 @@ else
|
||||
fi
|
||||
|
||||
|
||||
[[ -z "$mysql_credential_args" ]] && mysql_credential_args="$DEFAULT_MYSQL_CREDENTIAL_ARGS"
|
||||
#[[ -z "$mysql_credential_args" ]] && mysql_credential_args="$DEFAULT_MYSQL_CREDENTIAL_ARGS"
|
||||
|
||||
if [[ -z "$mysql_credential_args" ]]; then
|
||||
|
||||
detect_mysql_version
|
||||
|
||||
MAJOR_VERSION="$MYSQL_MAJOR_VERSION"
|
||||
MINOR_VERSION="$MYSQL_MINOR_VERSION"
|
||||
PATCH_LEVEL="$MYSQL_PATCH_LEVEL"
|
||||
|
||||
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] && ([[ $MAJOR_VERSION -gt 10 ]] \
|
||||
|| ( [[ $MAJOR_VERSION -eq 10 ]] && [[ $MINOR_VERSION -gt 3 ]] )) ; then
|
||||
if [[ -S "/tmp/mysql.sock" ]]; then
|
||||
mysql_credential_args="-u root -S /tmp/mysql.sock"
|
||||
elif [[ -S "/var/run/mysqld/mysqld.sock" ]]; then
|
||||
mysql_credential_args="-u root -S /var/run/mysqld/mysqld.sock"
|
||||
else
|
||||
fatal "Parameter 'MYSQL_CREDENTIAL_ARGS' cannot be determined automated.
|
||||
|
||||
Use configuration file "$conf_file" to set
|
||||
parameter manually."
|
||||
fi
|
||||
else
|
||||
if [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then
|
||||
mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf"
|
||||
elif [[ -f "/etc/mysql/debian.cnf" ]] ; then
|
||||
mysql_credential_args="--defaults-file=/etc/mysql/debian.cnf"
|
||||
else
|
||||
fatal "Parameter 'MYSQL_CREDENTIAL_ARGS' cannot be determined automated.
|
||||
|
||||
Use configuration file "$conf_file" to set
|
||||
parameter manually."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -z "$log_file" ]] && log_file="$DEFAULT_LOG_FILE"
|
||||
|
||||
if [[ ${#mysql_credential_args_arr[@]} -eq 0 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user