#!/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 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 docker-registry.pippiandcarlos.com/openbook_database ${mysql_args} exit 0