mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 05:29:30 +00:00
Rewrite find_my_cnf_file() so if a port is given only that port's cnf is returned, else nothing.
This commit is contained in:
@@ -793,22 +793,21 @@ find_my_cnf_file() {
|
||||
local port="${2:-""}"
|
||||
|
||||
local cnf_file=""
|
||||
if test -n "$port" && grep -- "/mysqld.*--port=$port" "${file}" >/dev/null 2>&1 ; then
|
||||
cnf_file="$(grep -- "/mysqld.*--port=$port" "${file}" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
|
||||
| head -n1)"
|
||||
|
||||
if [ "$port" ]; then
|
||||
cnf_file="$(grep --max-count 1 "/mysqld.*--port=$port" "$file" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }')"
|
||||
else
|
||||
cnf_file="$(grep '/mysqld' "${file}" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
|
||||
| head -n1)"
|
||||
cnf_file="$(grep --max-count 1 '/mysqld' "$file" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }')"
|
||||
fi
|
||||
|
||||
if [ ! -n "${cnf_file}" ]; then
|
||||
cnf_file="/etc/my.cnf";
|
||||
if [ ! -e "${cnf_file}" ]; then
|
||||
cnf_file="/etc/mysql/my.cnf";
|
||||
fi
|
||||
if [ ! -e "${cnf_file}" ]; then
|
||||
if [ -z "$cnf_file" ]; then
|
||||
if [ -e "/etc/my.cnf" ]; then
|
||||
cnf_file="/etc/my.cnf"
|
||||
elif [ -e "/etc/mysql/my.cnf" ]; then
|
||||
cnf_file="/etc/mysql/my.cnf"
|
||||
elif [ -e "/var/db/mysql/my.cnf" ]; then
|
||||
cnf_file="/var/db/mysql/my.cnf";
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user