zulip/scripts/setup/configure-rabbitmq

26 lines
832 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
#
# Delete the "guest" default user and replace it with a Zulip user
# with a real password
set -e
set -x
if [ "$EUID" -eq 0 ]; then
rabbitmqctl=(rabbitmqctl)
else
rabbitmqctl=(sudo rabbitmqctl)
fi
if [ -n "$RABBITMQ_NODE" ]; then
rabbitmqctl+=(-n "$RABBITMQ_NODE")
fi
RABBITMQ_USERNAME=$("$(dirname "$0")/../get-django-setting" RABBITMQ_USERNAME)
RABBITMQ_PASSWORD=$("$(dirname "$0")/../get-django-setting" RABBITMQ_PASSWORD)
"${rabbitmqctl[@]}" delete_user "$RABBITMQ_USERNAME" || true
"${rabbitmqctl[@]}" delete_user zulip || true
"${rabbitmqctl[@]}" delete_user guest || true
"${rabbitmqctl[@]}" add_user "$RABBITMQ_USERNAME" "$RABBITMQ_PASSWORD"
"${rabbitmqctl[@]}" set_user_tags "$RABBITMQ_USERNAME" administrator
"${rabbitmqctl[@]}" set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*'