kolla/docker/common/rabbitmq/config-rabbit.sh
Michal Rostecki 802b118bfa Add RabbitMQ image for Ubuntu
Dockerfile for RabbitMQ server installed from Ubuntu
Cloud Archive.

Partially implements: blueprint install-from-ubuntu

Change-Id: Ie90cbc4bea943b81b966d7b391b4de6df2e68364
2015-07-09 19:22:22 +02:00

57 lines
1.7 KiB
Bash

#!/bin/bash
RABBITMQ_CLUSTER_CONFIGURATION=""
function configure_files {
sed -i '
s|@RABBITMQ_USER@|'"$RABBITMQ_USER"'|g
s|@RABBITMQ_PASS@|'"$RABBITMQ_PASS"'|g
s|@RABBITMQ_CLUSTER_CONFIGURATION@|'"$RABBITMQ_CLUSTER_CONFIGURATION"'|g
' /etc/rabbitmq/rabbitmq.config
sed -i '
s|@RABBITMQ_LOG_BASE@|'"$RABBITMQ_LOG_BASE"'|g
' /etc/rabbitmq/rabbitmq-env.conf
}
function set_rabbitmq_cookie {
echo "${RABBITMQ_CLUSTER_COOKIE}" > /var/lib/rabbitmq/.erlang.cookie
chown rabbitmq: /var/lib/rabbitmq/.erlang.cookie
chmod 400 /var/lib/rabbitmq/.erlang.cookie
}
function configure_cluster {
check_required_vars RABBITMQ_CLUSTER_COOKIE RABBITMQ_CLUSTER_NODES
set_rabbitmq_cookie
HOSTNAME=""
IP_ADDRESS=""
DELIMETER=""
for node in ${RABBITMQ_CLUSTER_NODES}; do
HOSTNAME=`echo ${node} | cut -d'@' -f1`
IP_ADDRESS=`echo ${node} | cut -d'@' -f2`
CLUSTER_NODES="${CLUSTER_NODES}${DELIMETER}rabbit@${HOSTNAME}"
echo "${IP_ADDRESS} ${HOSTNAME}" >> /etc/hosts
DELIMETER=","
done
RABBITMQ_CLUSTER_CONFIGURATION="{cluster_nodes, {[$CLUSTER_NODES], disc}},"
}
function configure_rabbit {
if [ "$RABBITMQ_CLUSTER_NODES" ] && [ "$RABBITMQ_CLUSTER_COOKIE" ]; then
configure_cluster
elif [ "$RABBITMQ_SERVICE_HOST" ]; then
# work around:
# https://bugs.launchpad.net/ubuntu/+source/rabbitmq-server/+bug/653405
HOSTNAME=`/usr/bin/hostname -s 2> /dev/null || /bin/hostname 2> /dev/null`
echo "${RABBITMQ_SERVICE_HOST} ${HOSTNAME}" > /etc/hosts
else
echo "You need RABBITMQ_SERVICE_HOST or RABBITMQ_CLUSTER_NODES & " \
" RABBITMQ_CLUSTER_COOKIES variables"
exit 1
fi
configure_files
}