#!/bin/bash


wget https://objectstorage.ap-seoul-1.oraclecloud.com/n/cnk8d6fazu16/b/seoul/o/socat-1.7.3.2-5.el7.lux.x86_64.rpm
rpm -ivh socat-1.7.3.2-5.el7.lux.x86_64.rpm

wget https://objectstorage.ap-seoul-1.oraclecloud.com/n/cnk8d6fazu16/b/seoul/o/erlang-18.3-1.el7.centos.x86_64.rpm

rpm -ivh erlang-18.3-1.el7.centos.x86_64.rpm

wget https://objectstorage.ap-seoul-1.oraclecloud.com/n/cnk8d6fazu16/b/seoul/o/rabbitmq-server-3.6.5-1.noarch.rpm

rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm

RabbitMQDataPath=/data/rabbitmq
mkdir -p ${RabbitMQDataPath} && mkdir -p ${RabbitMQDataPath}/logs
chmod -R 777 ${RabbitMQDataPath}
chown -R rabbitmq:rabbitmq ${RabbitMQDataPath} && chown -R rabbitmq:rabbitmq ${RabbitMQDataPath}/logs

cat >>/etc/rabbitmq/rabbitmq-env.conf <<EOF
RABBITMQ_MNESIA_BASE=${RabbitMQDataPath}
RABBITMQ_LOG_BASE=${RabbitMQDataPath}/logs
EOF
chmod -R 644 /etc/rabbitmq/

systemctl start rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
systemctl restart rabbitmq-server
systemctl enable rabbitmq-server

rabbitmqctl add_user etour eTour@5672
rabbitmqctl set_user_tags etour administrator