move databases option to script args
This commit is contained in:
@ -1,3 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
log_file=replication.log
|
log_file=replication.log
|
||||||
databases=( 'database_one' 'another_database' )
|
|
||||||
|
@ -6,6 +6,33 @@ set -a
|
|||||||
. "${CONFIG_FILE}"
|
. "${CONFIG_FILE}"
|
||||||
set +a
|
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[@]}
|
for i in ${databases[@]}
|
||||||
do
|
do
|
||||||
REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
|
REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
|
||||||
|
Reference in New Issue
Block a user