diff options
Diffstat (limited to 'mariadb-push-replica.sh')
-rwxr-xr-x | mariadb-push-replica.sh | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/mariadb-push-replica.sh b/mariadb-push-replica.sh deleted file mode 100755 index d645c91..0000000 --- a/mariadb-push-replica.sh +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | set -ex | ||
3 | |||
4 | default_slave_remote_file=data/default-slave-remote | ||
5 | master_password_file=data/mysql-master-password | ||
6 | |||
7 | if [ -r "$default_slave_remote_file" ] | ||
8 | then | ||
9 | read default_remote_host < "$default_slave_remote_file" | ||
10 | fi | ||
11 | |||
12 | gen_password() | ||
13 | { | ||
14 | generated_password_length=32 | ||
15 | generated_password=$(tr -cd a-zA-Z0-9 < /dev/urandom | head -c "$generated_password_length") | ||
16 | [ "${#generated_password}" -eq "$generated_password_length" ] | ||
17 | printf '%s\n' "$generated_password" | ||
18 | } | ||
19 | |||
20 | if ! [ -e "$master_password_file" ] | ||
21 | then | ||
22 | gen_password > "$master_password_file" | ||
23 | fi | ||
24 | |||
25 | if [ -r "$master_password_file" ] | ||
26 | then | ||
27 | read master_password < "$master_password_file" | ||
28 | [ "${#master_password}" -ge 30 ] | ||
29 | fi | ||
30 | |||
31 | our_host=$(hostname --fqdn) | ||
32 | remote_host=${1:-$default_remote_host} | ||
33 | |||
34 | [ "$our_host" ] | ||
35 | [ "$remote_host" ] | ||
36 | |||
37 | master_password=$(false) | ||
38 | |||
39 | ssh -l root "$remote_host" -- mariadb <<END | ||
40 | CHANGE MASTER TO | ||
41 | MASTER_HOST='$our_host', | ||
42 | MASTER_USER='replication', | ||
43 | MASTER_PASSWORD='$master_password' | ||
44 | END | ||