repair_mysql_tables.sh: fix errors for support of multiple installations.
This commit is contained in:
parent
170cb05242
commit
77f29da0ac
@ -182,8 +182,9 @@ fi
|
||||
# -------------
|
||||
|
||||
if [[ -n "$1" ]] ; then
|
||||
DATABASES="$1"
|
||||
GIVEN_DATABASE="$1"
|
||||
else
|
||||
GIVEN_DATABASE=""
|
||||
if $terminal ; then
|
||||
|
||||
warn "No Databses given!"
|
||||
@ -252,16 +253,27 @@ for _val in ${mysql_credential_args_arr[@]} ; do
|
||||
mysql_version="${_val_arr[0]}"
|
||||
mysql_credential_args="${_val_arr[1]}"
|
||||
|
||||
DATABASES="$($mysql $mysql_credential_args -N -s -e "show databases")"
|
||||
|
||||
if [[ -z "$DATABASES" ]] ; then
|
||||
if [[ -z "$GIVEN_DATABASE" ]] ; then
|
||||
|
||||
if $terminal ; then
|
||||
echo ""
|
||||
echo -e "[ \033[37m\033[1mMySQL $mysql_version\033[m ]: repair (and optimize) tables of databases at host '$(hostname -f)'."
|
||||
fi
|
||||
|
||||
DATABASES="$($mysql $mysql_credential_args -N -s -e "show databases")"
|
||||
ALL_DATABASES=true
|
||||
else
|
||||
found=false
|
||||
for db in $DATABASES ; do
|
||||
if [[ "$db" = "$GIVEN_DATABASE" ]]; then
|
||||
DATABASES="$GIVEN_DATABASE"
|
||||
found=true
|
||||
fi
|
||||
done
|
||||
if ! $found ; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
length_table_name=0
|
||||
@ -273,7 +285,11 @@ for _val in ${mysql_credential_args_arr[@]} ; do
|
||||
|
||||
if $terminal ;then
|
||||
echo ""
|
||||
echo -e " [$(date)] Repair (and optimize) tables in database '${db}'.."
|
||||
if [[ -n "$GIVEN_DATABASE" ]] ; then
|
||||
echo -e " [$(date)] Repair (and optimize) tables in database '${db}'.."
|
||||
else
|
||||
echo -e " [ \033[37m\033[1mMySQL $mysql_version\033[m $(date) ] Repair (and optimize) tables in database '${db}'.."
|
||||
fi
|
||||
fi
|
||||
|
||||
TABLES="$($mysql $mysql_credential_args $db -N -s -e "show tables" 2> $tmp_log_file )"
|
||||
|
Loading…
Reference in New Issue
Block a user