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)
|
2019-03-15 01:08:55 +01:00
|
|
|
|
2020-10-16 00:14:26 +02:00
|
|
|
# Wait for RabbitMQ to start up
|
2021-12-03 21:03:16 +01:00
|
|
|
retries=29
|
2022-03-12 22:40:49 +01:00
|
|
|
# Could use rabbitmqctl await_startup when we upgrade to 3.7.11.
|
2022-04-16 01:05:21 +02:00
|
|
|
while ! rabbitmqctl -q await_online_nodes 1 2>/dev/null; do
|
2022-03-12 22:40:49 +01:00
|
|
|
if ((retries == 29)); then
|
|
|
|
echo "Waiting for RabbitMQ to start up..."
|
|
|
|
fi
|
2020-10-16 00:14:26 +02:00
|
|
|
sleep 1
|
|
|
|
if ! ((retries -= 1)); then
|
2022-04-16 01:05:21 +02:00
|
|
|
rabbitmqctl -q await_online_nodes 1
|
2020-10-16 00:14:26 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
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
|
|
|
|
rabbitmqctl set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*'
|