move databases option to script args

This commit is contained in:
2020-07-04 19:48:59 +03:00
parent 5c53cc453e
commit b73c27f3e2
2 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,2 @@
#!/bin/bash
log_file=replication.log
databases=( 'database_one' 'another_database' )

View File

@ -6,6 +6,33 @@ set -a
. "${CONFIG_FILE}"
set +a
readopt='getopts $opts opt;rc=$?;[ $rc$opt == 0? ]&&exit 1;[ $rc == 0 ]||{ shift $[OPTIND-1];false; }'
opts=vfdo:
# Enumerating options
#while eval $readopt
#do
# echo OPT:$opt ${OPTARG+OPTARG:$OPTARG}
#done
# Enumerating arguments
databases=( )
for arg
do
databases=( $databases $arg )
done
if [[ -z "$databases" ]]; then
cat <<EOF
Usage: $0 database_one [...database_two]
EOF
exit
fi
echo "Set replication databases to: ${databases[@]}"
for i in ${databases[@]}
do
REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'