summaryrefslogtreecommitdiff
path: root/templates/database/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'templates/database/run.sh')
-rwxr-xr-xtemplates/database/run.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/templates/database/run.sh b/templates/database/run.sh
new file mode 100755
index 0000000..9a61648
--- /dev/null
+++ b/templates/database/run.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# find other running nodes
+other_nodes_found=1
+for i in $(echo "{{ openbook_gcomm_addresses }}" | sed -e 's|,| |g'); do
+ if [ "${i}" != "{{ ansible_default_ipv4.address }}" ]; then
+ nc ${i} 4567 </dev/null >/dev/null
+ if [ "${?}" == "0" ]; then
+ other_nodes_found=0
+ fi
+ fi
+done
+
+# bootstrap or cluster join depending on whether other nodes were found
+if [ "${other_nodes_found}" == "0" ]; then
+ mysql_args=""
+else
+ mysql_args="--wsrep-new-cluster"
+fi
+
+docker run -d --rm --net=host -p 3306:3306 -p 4444:4444 -p 4567:4567 -p 4567:4567/udp -p 4568:4568 -p 9200:9200 -v /etc/openbook/database:/etc/mysql -v /var/lib/mysql:/var/lib/mysql -v /var/log/mysql:/var/log/mysql --name database openbook-docker-registry.verizoncloudplatform.com/openbook_database ${mysql_args}
+
+exit 0