summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/wsrep_sst_common.sh')
-rw-r--r--scripts/wsrep_sst_common.sh321
1 files changed, 193 insertions, 128 deletions
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index deebe7cf820..d4d9a58897d 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2021 MariaDB
+# Copyright (C) 2017-2022 MariaDB
# Copyright (C) 2012-2015 Codership Oy
#
# This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,62 @@ set -ue
# Setting the path for some utilities on CentOS
export PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin"
+trim_string()
+{
+ if [ -n "$BASH_VERSION" ]; then
+ local pattern="[![:space:]${2:-}]"
+ local x="${1#*$pattern}"
+ local z=${#1}
+ x=${#x}
+ if [ $x -ne $z ]; then
+ local y="${1%$pattern*}"
+ y=${#y}
+ x=$(( z-x-1 ))
+ y=$(( y-x+1 ))
+ printf '%s' "${1:$x:$y}"
+ else
+ printf ''
+ fi
+ else
+ local pattern="[[:space:]${2:-}]"
+ echo "$1" | sed -E "s/^$pattern+|$pattern+\$//g"
+ fi
+}
+
+trim_dir()
+{
+ local t=$(trim_string "$1")
+ if [ "$t" != '/' ]; then
+ if [ "${t%/}" != "$t" ]; then
+ t=$(trim_string "${t%/}")
+ fi
+ else
+ t='.'
+ fi
+ if [ -n "$BASH_VERSION" ]; then
+ printf '%s' "$t"
+ else
+ echo "$t"
+ fi
+}
+
+to_minuses()
+{
+ local x="$1"
+ local t="${1#*_}"
+ local r=""
+ while [ "$t" != "$x" ]; do
+ r="$r${x%%_*}-"
+ x="$t"
+ t="${t#*_}"
+ done
+ if [ -n "$BASH_VERSION" ]; then
+ printf '%s' "$r$x"
+ else
+ echo "$r$x"
+ fi
+}
+
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
WSREP_SST_OPT_BINLOG_INDEX=""
@@ -43,10 +99,9 @@ WSREP_SST_OPT_ADDR=""
WSREP_SST_OPT_ADDR_PORT=""
WSREP_SST_OPT_HOST=""
WSREP_SST_OPT_HOST_UNESCAPED=""
-WSREP_SST_OPT_HOST_ESCAPED=""
-INNODB_DATA_HOME_DIR="${INNODB_DATA_HOME_DIR:-}"
-INNODB_LOG_GROUP_HOME="${INNODB_LOG_GROUP_HOME:-}"
-INNODB_UNDO_DIR="${INNODB_UNDO_DIR:-}"
+INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}")
+INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}")
+INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}")
INNODB_FORCE_RECOVERY=""
INNOEXTRA=""
@@ -66,20 +121,22 @@ case "$1" in
# without square brackets:
readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}"
# Square brackets are needed in most cases:
- readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
- readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
+ readonly WSREP_SST_OPT_HOST="[$WSREP_SST_OPT_HOST_UNESCAPED]"
# Mark this address as IPv6:
readonly WSREP_SST_OPT_HOST_IPv6=1
+ # Let's remove the leading part that contains the host address:
+ remain="${WSREP_SST_OPT_ADDR#*\]}"
;;
*)
readonly WSREP_SST_OPT_HOST="${WSREP_SST_OPT_ADDR%%[:/]*}"
readonly WSREP_SST_OPT_HOST_UNESCAPED="$WSREP_SST_OPT_HOST"
- readonly WSREP_SST_OPT_HOST_ESCAPED="$WSREP_SST_OPT_HOST"
readonly WSREP_SST_OPT_HOST_IPv6=0
+ # Let's remove the leading part that contains the host address:
+ remain="${WSREP_SST_OPT_ADDR#*[:/]}"
;;
esac
- # Let's remove the leading part that contains the host address:
- remain="${WSREP_SST_OPT_ADDR#$WSREP_SST_OPT_HOST_ESCAPED}"
+ # If there is nothing but the address, then the remainder is empty:
+ [ "$remain" = "$WSREP_SST_OPT_ADDR" ] && remain=""
# Let's remove the ":" character that separates the port number
# from the hostname:
remain="${remain#:}"
@@ -87,39 +144,32 @@ case "$1" in
# up to "/" (if present):
WSREP_SST_OPT_ADDR_PORT="${remain%%/*}"
# If the "/" character is present, then the path is not empty:
- if [ "${remain#*/}" != "$remain" ]; then
+ if [ "$WSREP_SST_OPT_ADDR_PORT" != "$remain" ]; then
# This operation removes everything up to the "/" character,
# effectively removing the port number from the string:
readonly WSREP_SST_OPT_PATH="${remain#*/}"
else
readonly WSREP_SST_OPT_PATH=""
fi
- # The rest of the string is the same as the path (for now):
- remain="$WSREP_SST_OPT_PATH"
- # If there is one more "/" in the string, then everything before
- # it will be the module name, otherwise the module name is empty:
- if [ "${remain%%/*}" != "$remain" ]; then
- # This operation removes the tail after the very first
- # occurrence of the "/" character (inclusively):
- readonly WSREP_SST_OPT_MODULE="${remain%%/*}"
- else
- readonly WSREP_SST_OPT_MODULE=""
- fi
# Remove the module name part from the string, which ends with "/":
remain="${WSREP_SST_OPT_PATH#*/}"
- # If the rest of the string does not match the original, then there
- # was something else besides the module name:
+ # This operation removes the tail after the very first occurrence
+ # of the "/" character, inclusively:
+ readonly WSREP_SST_OPT_MODULE="${WSREP_SST_OPT_PATH%%/*}"
+ # If there is one more "/" in the string, then everything before
+ # it will be the LSN, otherwise the LSN is empty:
if [ "$remain" != "$WSREP_SST_OPT_PATH" ]; then
# Extract the part that matches the LSN by removing all
# characters starting from the very first "/":
readonly WSREP_SST_OPT_LSN="${remain%%/*}"
# Exctract everything after the first occurrence of
# the "/" character in the string:
+ source="$remain"
remain="${remain#*/}"
# If the remainder does not match the original string,
# then there is something else (the version number in
# our case):
- if [ "$remain" != "$WSREP_SST_OPT_LSN" ]; then
+ if [ "$remain" != "$source" ]; then
# Let's extract the version number by removing the tail
# after the very first occurence of the "/" character
# (inclusively):
@@ -138,22 +188,22 @@ case "$1" in
;;
'--datadir')
# Let's remove the trailing slash:
- readonly WSREP_SST_OPT_DATA="${2%/}"
+ readonly WSREP_SST_OPT_DATA=$(trim_dir "$2")
shift
;;
'--innodb-data-home-dir')
# Let's remove the trailing slash:
- readonly INNODB_DATA_HOME_DIR="${2%/}"
+ readonly INNODB_DATA_HOME_DIR=$(trim_dir "$2")
shift
;;
'--innodb-log-group-home-dir')
# Let's remove the trailing slash:
- readonly INNODB_LOG_GROUP_HOME="${2%/}"
+ readonly INNODB_LOG_GROUP_HOME=$(trim_dir "$2")
shift
;;
'--innodb-undo-directory')
# Let's remove the trailing slash:
- readonly INNODB_UNDO_DIR="${2%/}"
+ readonly INNODB_UNDO_DIR=$(trim_dir "$2")
shift
;;
'--defaults-file')
@@ -182,14 +232,12 @@ case "$1" in
readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}"
# Square brackets are needed in most cases:
readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
- readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
# Mark this address as IPv6:
readonly WSREP_SST_OPT_HOST_IPv6=1
;;
*)
readonly WSREP_SST_OPT_HOST="$2"
readonly WSREP_SST_OPT_HOST_UNESCAPED="$2"
- readonly WSREP_SST_OPT_HOST_ESCAPED="$2"
readonly WSREP_SST_OPT_HOST_IPv6=0
;;
esac
@@ -247,6 +295,7 @@ case "$1" in
'--mysqld-args')
original_cmd=""
shift
+ cmd_tail=0
while [ $# -gt 0 ]; do
lname="${1#--}"
# "--" is interpreted as the end of the list of options:
@@ -261,7 +310,7 @@ case "$1" in
shift
done
fi
- break;
+ break
fi
# Make sure the argument does not start with "--", otherwise it
# is a long option, which is processed after this "if":
@@ -279,7 +328,7 @@ case "$1" in
else
# If it's not bash, then we need to use slow
# external utilities:
- option=$(echo "$options" | cut -c1-1)
+ option=$(echo "$options" | cut -c1)
fi
# And the subsequent characters consider option value:
value=""
@@ -301,15 +350,25 @@ case "$1" in
if [ "${2#-}" = "$2" ]; then
shift
value="$1"
+ elif [ "$2" = '--' ]; then
+ shift
+ if [ $# -gt 1 ]; then
+ cmd_tail=1
+ shift
+ value="$1"
+ fi
fi
fi
- if [ $option = 'h' ]; then
+ if [ "$option" = 'h' ]; then
if [ -z "$WSREP_SST_OPT_DATA" ]; then
- MYSQLD_OPT_DATADIR="${value%/}"
+ MYSQLD_OPT_DATADIR=$(trim_dir "$value")
fi
- elif [ $option != 'u' -a \
- $option != 'P' ]
+ elif [ "$option" != 'u' -a \
+ "$option" != 'P' ]
then
+ if [ $cmd_tail -ne 0 ]; then
+ option="$option --"
+ fi
if [ -z "$value" ]; then
slist="$slist$option"
elif [ -z "$slist" ]; then
@@ -317,9 +376,16 @@ case "$1" in
else
slist="$slist -$option '$value'"
fi
+ break
+ fi
+ if [ $cmd_tail -ne 0 ]; then
+ if [ -n "$slist" ]; then
+ slist="$slist --"
+ else
+ slist='-'
+ fi
fi
break
-
else
slist="$slist$option"
fi
@@ -329,7 +395,7 @@ case "$1" in
original_cmd="$original_cmd -$slist"
fi
elif [ -z "$options" ]; then
- # We found an equal sign without any characters after it:
+ # We found an minus sign without any characters after it:
original_cmd="$original_cmd -"
else
# We found a value that does not start with a minus -
@@ -338,12 +404,25 @@ case "$1" in
original_cmd="$original_cmd '$1'"
fi
shift
- continue;
+ if [ $cmd_tail -ne 0 ]; then
+ # All other arguments must be copied unchanged:
+ while [ $# -gt 0 ]; do
+ original_cmd="$original_cmd '$1'"
+ shift
+ done
+ break
+ fi
+ continue
fi
# Now we are sure that we are working with an option
# that has a "long" name, so remove all characters after
# the first equal sign:
option="${1%%=*}"
+ # If the option name contains underscores, then replace
+ # them to minuses:
+ if [ "${option#*_}" != "$option" ]; then
+ option=$(to_minuses "$option")
+ fi
# The "--loose-" prefix should not affect the recognition
# of the option name:
if [ "${option#--loose-}" != "$option" ]; then
@@ -370,49 +449,49 @@ case "$1" in
case "$option" in
'--innodb-data-home-dir')
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
- MYSQLD_OPT_INNODB_DATA_HOME_DIR="${value%/}"
+ MYSQLD_OPT_INNODB_DATA_HOME_DIR=$(trim_dir "$value")
fi
skip_mysqld_arg=1
;;
'--innodb-log-group-home-dir')
if [ -z "$INNODB_LOG_GROUP_HOME" ]; then
- MYSQLD_OPT_INNODB_LOG_GROUP_HOME="${value%/}"
+ MYSQLD_OPT_INNODB_LOG_GROUP_HOME=$(trim_dir "$value")
fi
skip_mysqld_arg=1
;;
'--innodb-undo-directory')
if [ -z "$INNODB_UNDO_DIR" ]; then
- MYSQLD_OPT_INNODB_UNDO_DIR="${value%/}"
+ MYSQLD_OPT_INNODB_UNDO_DIR=$(trim_dir "$value")
fi
skip_mysqld_arg=1
;;
'--innodb-force-recovery')
if [ -n "$value" -a "$value" != "0" ]; then
- INNODB_FORCE_RECOVERY="$value"
+ INNODB_FORCE_RECOVERY=$(trim_string "$value")
fi
skip_mysqld_arg=1
;;
'--log-bin')
if [ -z "$WSREP_SST_OPT_BINLOG" ]; then
- MYSQLD_OPT_LOG_BIN="$value"
+ MYSQLD_OPT_LOG_BIN=$(trim_string "$value")
fi
skip_mysqld_arg=1
;;
'--log-bin-index')
if [ -z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
- MYSQLD_OPT_LOG_BIN_INDEX="$value"
+ MYSQLD_OPT_LOG_BIN_INDEX=$(trim_string "$value")
fi
skip_mysqld_arg=1
;;
'--log-basename')
if [ -z "$WSREP_SST_OPT_LOG_BASENAME" ]; then
- MYSQLD_OPT_LOG_BASENAME="$value"
+ MYSQLD_OPT_LOG_BASENAME=$(trim_string "$value")
fi
skip_mysqld_arg=1
;;
'--datadir')
if [ -z "$WSREP_SST_OPT_DATA" ]; then
- MYSQLD_OPT_DATADIR="${value%/}"
+ MYSQLD_OPT_DATADIR=$(trim_dir "$value")
fi
skip_mysqld_arg=1
;;
@@ -471,8 +550,8 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
# If the WSREP_SST_OPT_BINLOG variable is not set, but
# --log-basename is present among the arguments to mysqld,
- # then set WSREP_SST_OPT_BINLOG equal to the base name with
- # the "-bin" suffix:
+ # then set WSREP_SST_OPT_BINLOG equal to the base name
+ # with the "-bin" suffix:
readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin"
else
# Take the default name:
@@ -525,26 +604,23 @@ get_binlog()
WSREP_SST_OPT_BINLOG_INDEX=$(parse_cnf '--mysqld' 'log-bin-index')
fi
# if no command line argument and WSREP_SST_OPT_LOG_BASENAME is not set,
- # try to get it from my.cnf:
+ # then try to get it from my.cnf:
if [ -z "$WSREP_SST_OPT_LOG_BASENAME" ]; then
WSREP_SST_OPT_LOG_BASENAME=$(parse_cnf '--mysqld' 'log-basename')
fi
if [ -z "$WSREP_SST_OPT_BINLOG" ]; then
- # If the --log-bin option is specified without a parameter,
+ # If the log-bin option is specified without a parameter,
# then we need to build the name of the index file according
# to the rules described in the server documentation:
- if [ -n "${MYSQLD_OPT_LOG_BIN+x}" -o \
- $(in_config '--mysqld' 'log-bin') -eq 1 ]
- then
+ if [ $(in_config '--mysqld' 'log-bin') -ne 0 ]; then
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
# If the WSREP_SST_OPT_BINLOG variable is not set, but
# --log-basename is present among the arguments of mysqld,
- # then set WSREP_SST_OPT_BINLOG equal to the base name with
- # the "-bin" suffix:
+ # then set WSREP_SST_OPT_BINLOG equal to the base name
+ # with the "-bin" suffix:
readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin"
else
- # If the --log-bin option is present without a value, then
- # we take the default name:
+ # Take the default name:
readonly WSREP_SST_OPT_BINLOG='mysql-bin'
fi
fi
@@ -554,13 +630,13 @@ get_binlog()
# it according to the specifications for the server:
if [ -z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
- # If the WSREP_SST_OPT_BINLOG variable is not set, but
+ # If the WSREP_SST_OPT_BINLOG_INDEX variable is not set, but
# --log-basename is present among the arguments of mysqld,
- # then set WSREP_SST_OPT_BINLOG equal to the base name with
- # the "-bin" suffix:
+ # then set WSREP_SST_OPT_BINLOG_INDEX equal to the base name
+ # with the "-bin" suffix:
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index"
else
- # the default name (note that base of this name
+ # Use the default name (note that base of this name
# is already defined above):
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index"
fi
@@ -594,27 +670,18 @@ if [ -n "$WSREP_SST_OPT_ADDR_PORT" ]; then
# the corresponding variable:
readonly WSREP_SST_OPT_PORT="$WSREP_SST_OPT_ADDR_PORT"
fi
-elif [ -n "$WSREP_SST_OPT_ADDR" ]; then
+else
# If the port is missing, take the default port:
if [ -z "$WSREP_SST_OPT_PORT" ]; then
readonly WSREP_SST_OPT_PORT=4444
fi
WSREP_SST_OPT_ADDR_PORT="$WSREP_SST_OPT_PORT"
- # Let's remove the leading part that contains the host address:
- remain="${WSREP_SST_OPT_ADDR#$WSREP_SST_OPT_HOST_ESCAPED}"
- # Let's remove the ":" character that separates the port number
- # from the hostname:
- remain="${remain#:}"
- # Let's remove all characters upto first "/" character that
- # separates the hostname with port number from the path:
- remain="${remain#/}"
- # Let's construct a new value for the address with the port:
- WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST:$WSREP_SST_OPT_PORT"
- if [ -n "$remain" ]; then
- WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_ADDR/$remain"
- fi
fi
+# Let's construct a new value for the address with the port:
+sst_path="${WSREP_SST_OPT_PATH:+/}$WSREP_SST_OPT_PATH"
+WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST:$WSREP_SST_OPT_PORT$sst_path"
+
readonly WSREP_SST_OPT_ADDR
readonly WSREP_SST_OPT_ADDR_PORT
@@ -632,7 +699,7 @@ commandex()
# try to use my_print_defaults, mysql and mysqldump that come
# with the sources (for MTR suite):
script_binary=$(dirname "$0")
-SCRIPTS_DIR=$(cd "$script_binary"; pwd -P)
+SCRIPTS_DIR=$(cd "$script_binary"; pwd)
EXTRA_DIR="$SCRIPTS_DIR/../extra"
CLIENT_DIR="$SCRIPTS_DIR/../client"
@@ -725,8 +792,11 @@ parse_cnf()
local group="${groups%%\|*}"
# Remove the remainder (the group name) from the rest
# of the groups list (as if it were a prefix):
- groups="${groups#$group}"
- groups="${groups#\|}"
+ if [ "$group" != "$groups" ]; then
+ groups="${groups#*\|}"
+ else
+ groups=""
+ fi
# If the group name is the same as the "mysqld" without "--" prefix,
# then try to use it together with the group suffix:
if [ "$group" = 'mysqld' -a -n "$WSREP_SST_OPT_SUFFIX_VALUE" ]; then
@@ -751,10 +821,16 @@ parse_cnf()
done
# Use default if we haven't found a value:
- if [ -z "$reval" ]; then
- [ -n "${3:-}" ] && reval="$3"
+ [ -z "$reval" ] && reval="${3:-}"
+
+ # Truncate spaces:
+ [ -n "$reval" ] && reval=$(trim_string "$reval")
+
+ if [ -n "$BASH_VERSION" ]; then
+ printf '%s' "$reval"
+ else
+ echo "$reval"
fi
- echo "$reval"
}
#
@@ -780,8 +856,11 @@ in_config()
local group="${groups%%\|*}"
# Remove the remainder (the group name) from the rest
# of the groups list (as if it were a prefix):
- groups="${groups#$group}"
- groups="${groups#\|}"
+ if [ "$group" != "$groups" ]; then
+ groups="${groups#*\|}"
+ else
+ groups=""
+ fi
# If the group name is the same as the "mysqld" without "--" prefix,
# then try to use it together with the group suffix:
if [ "$group" = 'mysqld' -a -n "$WSREP_SST_OPT_SUFFIX_VALUE" ]; then
@@ -804,7 +883,11 @@ in_config()
break
fi
done
- echo $found
+ if [ -n "$BASH_VERSION" ]; then
+ printf '%s' $found
+ else
+ echo $found
+ fi
}
wsrep_auth_not_set()
@@ -937,11 +1020,22 @@ wsrep_gen_secret()
{
get_openssl
if [ -n "$OPENSSL_BINARY" ]; then
- echo $("$OPENSSL_BINARY" rand -hex 16)
- else
- printf "%04x%04x%04x%04x%04x%04x%04x%04x" \
+ "$OPENSSL_BINARY" rand -hex 16
+ elif [ -n "$BASH_VERSION" ]; then
+ printf '%04x%04x%04x%04x%04x%04x%04x%04x' \
$RANDOM $RANDOM $RANDOM $RANDOM \
$RANDOM $RANDOM $RANDOM $RANDOM
+ elif [ -n "$(commandex cksum)" -a \
+ -n "$(commandex printf)" ]
+ then
+ printf '%08x%08x%08x%08x' \
+ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1) \
+ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1) \
+ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1) \
+ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1)
+ else
+ wsrep_log_error "Unable to generate 16-byte secret"
+ exit 22
fi
}
@@ -979,14 +1073,14 @@ is_local_ip()
if [ -n "$ip_util" ]; then
# ip address show ouput format is " inet[6] <address>/<mask>":
"$ip_util" address show \
- | grep -E "^[[:space:]]*inet.? [^[:space:]]+/" -o \
+ | grep -E '^[[:space:]]*inet.? [^[:space:]]+/' -o \
| grep -F " $1/" >/dev/null && return 0
else
local ifconfig_util=$(commandex 'ifconfig')
if [ -n "$ifconfig_util" ]; then
# ifconfig output format is " inet[6] <address> ...":
"$ifconfig_util" \
- | grep -E "^[[:space:]]*inet.? [^[:space:]]+ " -o \
+ | grep -E '^[[:space:]]*inet.? [^[:space:]]+ ' -o \
| grep -F " $1 " >/dev/null && return 0
fi
fi
@@ -1049,7 +1143,7 @@ check_port()
ss -nlpH "( sport = :$port )" 2>/dev/null | \
grep -q -E "users:\\(.*\\(\"($utils)[^[:space:]]*\"[^)]*,pid=$pid(,[^)]*)?\\)" && rc=0
else
- wsrep_log_error "unknown sockets utility"
+ wsrep_log_error "Unknown sockets utility"
exit 2 # ENOENT
fi
@@ -1158,13 +1252,6 @@ verify_cert_matches_key()
exit 22
fi
- # If the diff utility is not installed, then
- # we will not do this certificate check:
- if [ -z "$(commandex diff)" ]; then
- wsrep_log_info "diff utility not found"
- return
- fi
-
# If the openssl utility is not installed, then
# we will not do this certificate check:
get_openssl
@@ -1175,9 +1262,9 @@ verify_cert_matches_key()
# Generate the public key from the cert and the key.
# They should match (otherwise we can't create an SSL connection).
- if ! diff <("$OPENSSL_BINARY" x509 -in "$cert" -pubkey -noout 2>/dev/null) \
- <("$OPENSSL_BINARY" pkey -in "$key" -pubout 2>/dev/null) >/dev/null 2>&1
- then
+ local pk1=$("$OPENSSL_BINARY" x509 -in "$cert" -pubkey -noout 2>/dev/null || :)
+ local pk2=$("$OPENSSL_BINARY" pkey -in "$key" -pubout 2>/dev/null || :)
+ if [ "$pk1" != "$pk2" ]; then
wsrep_log_error "******************* FATAL ERROR *****************"
wsrep_log_error "* The certificate and private key do not match. *"
wsrep_log_error "* Please check your certificate and key files. *"
@@ -1220,28 +1307,6 @@ check_for_version()
return 0
}
-trim_string()
-{
- if [ -n "$BASH_VERSION" ]; then
- local pattern="[![:space:]${2:-}]"
- local x="${1#*$pattern}"
- local z=${#1}
- x=${#x}
- if [ $x -ne $z ]; then
- local y="${1%$pattern*}"
- y=${#y}
- x=$(( z-x-1 ))
- y=$(( y-x+1 ))
- printf '%s' "${1:$x:$y}"
- else
- printf ''
- fi
- else
- local pattern="[[:space:]${2:-}]"
- echo "$1" | sed -E "s/^$pattern+|$pattern+\$//g"
- fi
-}
-
#
# Check whether process is still running.
# The first parameter contains the name of the PID file.
@@ -1272,6 +1337,10 @@ check_pid()
rm -f "$pid_file" || :
fi
fi
+ local config="${3:-}"
+ if [ -n "$config" -a -f "$config" ]; then
+ rm -f "$config" || :
+ fi
CHECK_PID=0
return 1
}
@@ -1377,13 +1446,9 @@ check_server_ssl_config()
fi
fi
if [ -n "$tcert" ]; then
- tcert=$(trim_string "$tcert")
if [ "${tcert%/}" != "$tcert" -o -d "$tcert" ]; then
tcap="$tcert"
tcert=""
fi
fi
- if [ -n "$tcap" ]; then
- tcap=$(trim_string "$tcap")
- fi
}