#!/usr/bin/sh

## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
##

SCRIPT="$(basename "$0")"

if [ "$(id -u)" -eq 0 ]; then
    cd ~rabbitmq 2>/dev/null || cd /
    exec runuser -u rabbitmq -- /usr/lib/rabbitmq/bin/"$SCRIPT" "$@"
else
    exec /usr/lib/rabbitmq/bin/"$SCRIPT" "$@"
fi
