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
|
2016-01-12 13:08:43 +01:00
|
|
|
set -e
|
|
|
|
set -x
|
2013-01-11 21:16:42 +01:00
|
|
|
|
2018-08-03 02:14:47 +02:00
|
|
|
RABBITMQ_FLAGS=()
|
2017-04-19 07:48:40 +02:00
|
|
|
if [ -n "$RABBITMQ_NODE" ]; then
|
2018-08-03 02:14:47 +02:00
|
|
|
RABBITMQ_FLAGS=(-n "$RABBITMQ_NODE")
|
2017-04-19 07:48:40 +02:00
|
|
|
fi
|
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
|
|
|
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
|
|
RABBITMQCTL_COMMAND="rabbitmqctl"
|
|
|
|
else
|
|
|
|
RABBITMQCTL_COMMAND="sudo rabbitmqctl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" delete_user "$RABBITMQ_USERNAME" || true
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" delete_user zulip || true
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" delete_user guest || true
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" add_user "$RABBITMQ_USERNAME" "$RABBITMQ_PASSWORD"
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" set_user_tags "$RABBITMQ_USERNAME" administrator
|
|
|
|
$RABBITMQCTL_COMMAND "${RABBITMQ_FLAGS[@]}" set_permissions -p / "$RABBITMQ_USERNAME" '.*' '.*' '.*'
|