#!/bin/bash

if [[ -e /.firstrun ]]; then
    /scripts/init_script.sh
fi

cd /home/quant_group/rabbitmq
touch nohup.out

echo "Starting RabbitMQ..."
nohup /usr/sbin/rabbitmq-server > /tmp/rabbitmq.out &

echo "sleep 15"
sleep 15

echo "get definitions from 192.168.4.15"
response=$(curl -X GET -H "Authorization: Basic cmFiYml0X2FkbWluOmFiYzEyMzQ=" "http://172.16.1.231:15672/api/definitions")
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic cWE6cWF0ZXN0" -d $response "http://localhost:15672/api/definitions"

tail -f /tmp/rabbitmq.out