From: Martin Schwenke Date: Mon, 8 Apr 2024 01:08:33 +0000 (+1000) Subject: ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn" X-Git-Tag: tdb-1.4.13~1246 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c354e358e59da2e0b5ad1d13d5b411458476ab3;p=thirdparty%2Fsamba.git ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn" Best reviewed with "git show -w". Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/events/legacy/00.ctdb.script b/ctdb/config/events/legacy/00.ctdb.script index 292081bbe06..d287e7ad8d7 100755 --- a/ctdb/config/events/legacy/00.ctdb.script +++ b/ctdb/config/events/legacy/00.ctdb.script @@ -3,7 +3,7 @@ # Event script for ctdb-specific setup and other things that don't fit # elsewhere. -[ -n "$CTDB_BASE" ] || \ +[ -n "$CTDB_BASE" ] || CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD") . "${CTDB_BASE}/functions" @@ -14,91 +14,91 @@ load_script_options # type is commonly supported and more portable than which(1) # shellcheck disable=SC2039 -select_tdb_checker () +select_tdb_checker() { - # Find the best TDB consistency check available. - use_tdb_tool_check=false - type tdbtool >/dev/null 2>&1 && found_tdbtool=true - type tdbdump >/dev/null 2>&1 && found_tdbdump=true - - if $found_tdbtool && echo "help" | tdbtool | grep -q check ; then - use_tdb_tool_check=true - elif $found_tdbtool && $found_tdbdump ; then - cat </dev/null 2>&1 && found_tdbtool=true + type tdbdump >/dev/null 2>&1 && found_tdbdump=true + + if $found_tdbtool && echo "help" | tdbtool | grep -q check; then + use_tdb_tool_check=true + elif $found_tdbtool && $found_tdbdump; then + cat </dev/null | - grep -q "Database integrity is OK" ; then - return 0 + _db="$1" + + if $use_tdb_tool_check; then + # tdbtool always exits with 0 :-( + if timeout 10 tdbtool "$_db" check 2>/dev/null | + grep -q "Database integrity is OK"; then + return 0 + else + return 1 + fi else - return 1 + timeout 10 tdbdump "$_db" >/dev/null 2>/dev/null + return $? fi - else - timeout 10 tdbdump "$_db" >/dev/null 2>/dev/null - return $? - fi } -check_persistent_databases () +check_persistent_databases() { - _dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_VARDIR}/persistent}" - [ -d "$_dir" ] || return 0 - - for _db in "$_dir/"*.tdb.*[0-9] ; do - [ -r "$_db" ] || continue - check_tdb "$_db" || \ - die "Persistent database $_db is corrupted! CTDB will not start." - done + _dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_VARDIR}/persistent}" + [ -d "$_dir" ] || return 0 + + for _db in "$_dir/"*.tdb.*[0-9]; do + [ -r "$_db" ] || continue + check_tdb "$_db" || + die "Persistent database $_db is corrupted! CTDB will not start." + done } -check_non_persistent_databases () +check_non_persistent_databases() { - _dir="${CTDB_DBDIR:-${CTDB_VARDIR}}" - [ -d "$_dir" ] || return 0 - - for _db in "${_dir}/"*.tdb.*[0-9] ; do - [ -r "$_db" ] || continue - check_tdb "$_db" || { - _backup="${_db}.$(date +'%Y%m%d.%H%M%S').corrupt" - cat <