summaryrefslogtreecommitdiff
path: root/mariadb-push-replica.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mariadb-push-replica.sh')
-rwxr-xr-xmariadb-push-replica.sh44
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
2set -ex
3
4default_slave_remote_file=data/default-slave-remote
5master_password_file=data/mysql-master-password
6
7if [ -r "$default_slave_remote_file" ]
8then
9 read default_remote_host < "$default_slave_remote_file"
10fi
11
12gen_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
20if ! [ -e "$master_password_file" ]
21then
22 gen_password > "$master_password_file"
23fi
24
25if [ -r "$master_password_file" ]
26then
27 read master_password < "$master_password_file"
28 [ "${#master_password}" -ge 30 ]
29fi
30
31our_host=$(hostname --fqdn)
32remote_host=${1:-$default_remote_host}
33
34[ "$our_host" ]
35[ "$remote_host" ]
36
37master_password=$(false)
38
39ssh -l root "$remote_host" -- mariadb <<END
40CHANGE MASTER TO
41 MASTER_HOST='$our_host',
42 MASTER_USER='replication',
43 MASTER_PASSWORD='$master_password'
44END