diff --git a/10.11-ubi/healthcheck.sh b/10.11-ubi/healthcheck.sh index eeecbcce..b637f908 100755 --- a/10.11-ubi/healthcheck.sh +++ b/10.11-ubi/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/10.11/healthcheck.sh b/10.11/healthcheck.sh index eeecbcce..b637f908 100755 --- a/10.11/healthcheck.sh +++ b/10.11/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/10.5/healthcheck.sh b/10.5/healthcheck.sh index b110f973..e8278024 100755 --- a/10.5/healthcheck.sh +++ b/10.5/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mysql ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/10.6-ubi/healthcheck.sh b/10.6-ubi/healthcheck.sh index eeecbcce..b637f908 100755 --- a/10.6-ubi/healthcheck.sh +++ b/10.6-ubi/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/10.6/healthcheck.sh b/10.6/healthcheck.sh index eeecbcce..b637f908 100755 --- a/10.6/healthcheck.sh +++ b/10.6/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/11.1/healthcheck.sh b/11.1/healthcheck.sh index 33794d8d..fffbd3e9 100755 --- a/11.1/healthcheck.sh +++ b/11.1/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/11.2/healthcheck.sh b/11.2/healthcheck.sh index 33794d8d..fffbd3e9 100755 --- a/11.2/healthcheck.sh +++ b/11.2/healthcheck.sh @@ -65,24 +65,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/11.4-ubi/healthcheck.sh b/11.4-ubi/healthcheck.sh index 29294c36..614a5423 100755 --- a/11.4-ubi/healthcheck.sh +++ b/11.4-ubi/healthcheck.sh @@ -66,25 +66,32 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/11.4/healthcheck.sh b/11.4/healthcheck.sh index 29294c36..614a5423 100755 --- a/11.4/healthcheck.sh +++ b/11.4/healthcheck.sh @@ -66,25 +66,32 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/11.5/healthcheck.sh b/11.5/healthcheck.sh index 29294c36..9aad84ac 100755 --- a/11.5/healthcheck.sh +++ b/11.5/healthcheck.sh @@ -66,25 +66,31 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select 1' 2>&1) + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/healthcheck.sh b/healthcheck.sh index 29294c36..614a5423 100755 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -66,25 +66,32 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/main-ubi/healthcheck.sh b/main-ubi/healthcheck.sh index 29294c36..614a5423 100755 --- a/main-ubi/healthcheck.sh +++ b/main-ubi/healthcheck.sh @@ -66,25 +66,32 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s } diff --git a/main/healthcheck.sh b/main/healthcheck.sh index 29294c36..614a5423 100755 --- a/main/healthcheck.sh +++ b/main/healthcheck.sh @@ -66,25 +66,32 @@ connect() return "$s"; ;; esac - # falling back to this if there wasn't a connection answer. - set +e +o pipefail - # (on second extra_file) - # shellcheck disable=SC2086 - mariadb ${nodefaults:+--no-defaults} \ + # falling back to tcp if there wasn't a connection answer. + s=$(mariadb ${nodefaults:+--no-defaults} \ ${def['file']:+--defaults-file=${def['file']}} \ ${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \ ${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \ --skip-ssl --skip-ssl-verify-server-cert \ - -h localhost --protocol tcp -e 'select 1' 2>&1 \ - | grep -qF "Can't connect" - local ret=${PIPESTATUS[1]} - set -eo pipefail - if (( "$ret" == 0 )); then - # grep Matched "Can't connect" so we fail - connect_s=1 - else - connect_s=0 - fi + -h localhost --protocol tcp -e 'select @@skip_networking' 2>&1) + + case "$s" in + 1) # skip-networking=1 (no network) + ;& + ERROR\ 2002\ \(HY000\):*) + # cannot connect + connect_s=1 + ;; + ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*) + # grep access denied and other 28000 client errors - we did connect + ;& + 0) # skip-networking=0 + connect_s=0 + ;; + *) + >&2 echo "Unknown error $s" + connect_s=1 + ;; + esac return $connect_s }