Browse Source

move databases option to script args

master
dimti 4 years ago
parent
commit
b73c27f3e2
  1. 1
      _config.sh
  2. 27
      start-replication.sh

1
_config.sh

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

27
start-replication.sh

@ -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;'

Loading…
Cancel
Save