2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
2013-01-11 21:16:42 +01:00
|
|
|
#
|
2013-08-06 21:32:15 +02:00
|
|
|
# Delete the "guest" default user and replace it with a Zulip user
|
2013-01-11 21:16:42 +01:00
|
|
|
# with a real password
|
2021-12-17 01:39:34 +01:00
|
|
|
set -eu
|
2013-01-11 21:16:42 +01:00
|
|
|
|
2021-12-07 21:55:38 +01:00
|
|
|
# If the RabbitMQ distribution cookie is insecure, reset it and
|
|
|
|
# restart RabbitMQ.
|
2022-04-16 01:05:21 +02:00
|
|
|
"$(dirname "$0")/generate-rabbitmq-cookie"
|
2021-12-07 21:55:38 +01:00
|
|
|
|
2016-05-08 04:02:32 +02:00
|
|
|
RABBITMQ_USERNAME=$("$(dirname "$0")/../get-django-setting" RABBITMQ_USERNAME)
|
|
|
|
RABBITMQ_PASSWORD=$("$(dirname "$0")/../get-django-setting" RABBITMQ_PASSWORD)
|
2024-05-31 17:47:15 +02:00
|
|
|
RABBITMQ_VHOST=$("$(dirname "$0")/../get-django-setting" RABBITMQ_VHOST)
|
2019-03-15 01:08:55 +01:00
|
|
|
|
2024-05-31 17:43:36 +02:00
|
|
|
rabbitmqctl await_startup
|
2022-04-16 01:05:21 +02:00
|
|
|
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
|
2024-05-31 17:47:15 +02:00
|
|
|
if ! rabbitmqctl list_vhosts --no-table-headers --quiet | grep -qx "$RABBITMQ_VHOST"; then
|
|
|
|
rabbitmqcql add_vhost "$RABBITMQ_VHOST"
|
|
|
|
fi
|
|
|
|
rabbitmqctl set_permissions -p "$RABBITMQ_VHOST" "$RABBITMQ_USERNAME" '.*' '.*' '.*'
|