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 VMware, Inc.
15 ## Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
18 # Escape spaces and quotes, because shell is revolting.
20 # Escape quotes in parameters, so that they're passed through cleanly.
21 arg=$(sed -e 's/"/\\"/g' <<-END
25 CMDLINE="${CMDLINE} \"${arg}\""
32 if [ `id -u` = `id -u rabbitmq` -a "$SCRIPT" = "rabbitmq-server" ] ; then
33 /usr/lib/rabbitmq/bin/rabbitmq-server "$@"
34 elif [ `id -u` = `id -u rabbitmq` -o "$SCRIPT" = "rabbitmq-plugins" ] ; then
35 /usr/lib/rabbitmq/bin/${SCRIPT} "$@"
36 elif [ `id -u` = 0 ] ; then
37 su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
39 /usr/lib/rabbitmq/bin/${SCRIPT}
41 echo "Only root or rabbitmq should run ${SCRIPT}"