2 ## The contents of this file are subject to the Mozilla Public License
3 ## Version 1.1 (the "License"); you may not use this file except in
4 ## compliance with the License. You may obtain a copy of the License
5 ## at http://www.mozilla.org/MPL/
7 ## Software distributed under the License is distributed on an "AS IS"
8 ## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 ## the License for the specific language governing rights and
10 ## limitations under the License.
12 ## The Original Code is RabbitMQ.
14 ## The Initial Developer of the Original Code is GoPivotal, Inc.
15 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
19 if [ $(uname -s) = "Linux" ]; then
24 # Wrap each arg in single quotes and wrap single quotes in double quotes, so that they're passed through cleanly.
25 arg=`printf %s "$arg" | sed $SED_OPT -e "s/'/'\"'\"'/g"`
26 CMDLINE="${CMDLINE} '${arg}'"
33 if [ `id -u` = `id -u rabbitmq` -a "$SCRIPT" = "rabbitmq-server" ] ; then
34 RABBITMQ_ENV=/usr/lib/rabbitmq/bin/rabbitmq-env
35 RABBITMQ_SCRIPTS_DIR=$(dirname "$RABBITMQ_ENV")
38 exec /usr/lib/rabbitmq/bin/rabbitmq-server "$@"
39 elif [ `id -u` = `id -u rabbitmq` -o "$SCRIPT" = "rabbitmq-plugins" ] ; then
40 if [ -f $PWD/.erlang.cookie ] ; then
43 exec /usr/lib/rabbitmq/bin/${SCRIPT} "$@"
44 elif [ `id -u` = 0 ] ; then
45 # WRS. Allow to run as root
46 export HOME=${HOME:-/root}
47 /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
49 /usr/lib/rabbitmq/bin/${SCRIPT}
51 echo "Only root or rabbitmq should run ${SCRIPT}"