mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 16:14:02 +00:00
This is required in order to lock down the RabbitMQ port to only listen on localhost. If the nodename is `rabbit@hostname`, in most circumstances the hostname will resolve to an external IP, which the rabbitmq port will not be bound to. Installs which used `rabbit@hostname`, due to RabbitMQ having been installed before Zulip, would not have functioned if the host or RabbitMQ service was restarted, as the localhost restrictions in the RabbitMQ configuration would have made rabbitmqctl (and Zulip cron jobs that call it) unable to find the rabbitmq server. The previous commit ensures that configure-rabbitmq is re-run after the nodename has changed. However, rabbitmq needs to be stopped before `rabbitmq-env.conf` is changed; we use an `onlyif` on an `exec` to print the warning about the node change, and let the subsequent config change and notify of the service and configure-rabbitmq to complete the re-configuration.
30 lines
913 B
Bash
Executable File
30 lines
913 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# For security reasons, we need to configure RabbitMQ to listen only
|
|
# on localhost, which we cannot do if the nodename contains the
|
|
# hostname (e.g. rabbit@zulip-host). Containing the hostname also
|
|
# makes it brittle to hostname changes, which are (for example) common
|
|
# in containerized environments.
|
|
|
|
set -eu
|
|
|
|
# Try to find the current nodename
|
|
CURRENT=$(sh -c 'cd /usr/lib/rabbitmq/bin/ && . ./rabbitmq-env && echo $NODENAME')
|
|
if [ "$CURRENT" != "zulip@localhost" ]; then
|
|
cat <<EOF
|
|
|
|
***** WARNING *****
|
|
|
|
We are renaming the rabbitmq server's nodename from '$CURRENT' to
|
|
'zulip@localhost', as rabbitmq is being reconfigured to listen only on
|
|
localhost. This will also make the server more resilient to hostname
|
|
changes. This will only affect you if you were using the rabbitmq
|
|
server for other, non-Zulip uses.
|
|
|
|
*******************
|
|
|
|
EOF
|
|
|
|
service rabbitmq-server stop || true
|
|
fi
|