|
Hubert Plociniczak |
1b1224 |
#!/bin/sh
|
|
Hubert Plociniczak |
1b1224 |
## The contents of this file are subject to the Mozilla Public License
|
|
Hubert Plociniczak |
1b1224 |
## Version 1.1 (the "License"); you may not use this file except in
|
|
Hubert Plociniczak |
1b1224 |
## compliance with the License. You may obtain a copy of the License at
|
|
Hubert Plociniczak |
1b1224 |
## http://www.mozilla.org/MPL/
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## Software distributed under the License is distributed on an "AS IS"
|
|
Hubert Plociniczak |
1b1224 |
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
Hubert Plociniczak |
1b1224 |
## License for the specific language governing rights and limitations
|
|
Hubert Plociniczak |
1b1224 |
## under the License.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## The Original Code is RabbitMQ.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## The Initial Developers of the Original Code are LShift Ltd,
|
|
Hubert Plociniczak |
1b1224 |
## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
|
|
Hubert Plociniczak |
1b1224 |
## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
|
|
Hubert Plociniczak |
1b1224 |
## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
|
|
Hubert Plociniczak |
1b1224 |
## Technologies LLC, and Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
|
|
Hubert Plociniczak |
1b1224 |
## Ltd. Portions created by Cohesive Financial Technologies LLC are
|
|
Hubert Plociniczak |
1b1224 |
## Copyright (C) 2007-2010 Cohesive Financial Technologies
|
|
Hubert Plociniczak |
1b1224 |
## LLC. Portions created by Rabbit Technologies Ltd are Copyright
|
|
Hubert Plociniczak |
1b1224 |
## (C) 2007-2010 Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## All Rights Reserved.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
## Contributor(s): ______________________________________.
|
|
Hubert Plociniczak |
1b1224 |
##
|
|
Hubert Plociniczak |
1b1224 |
|
|
Hubert Plociniczak |
cc9fdf |
# Escape spaces and quotes, because shell is revolting.
|
|
Hubert Plociniczak |
cc9fdf |
for arg in "$@" ; do
|
|
Hubert Plociniczak |
cc9fdf |
# Escape quotes in parameters, so that they're passed through cleanly.
|
|
Hubert Plociniczak |
1b1224 |
arg=$(sed -e 's/"/\\"/g' <<-END
|
|
Hubert Plociniczak |
cc9fdf |
$arg
|
|
Hubert Plociniczak |
cc9fdf |
END
|
|
Hubert Plociniczak |
cc9fdf |
)
|
|
Hubert Plociniczak |
cc9fdf |
CMDLINE="${CMDLINE} \"${arg}\""
|
|
Hubert Plociniczak |
cc9fdf |
done
|
|
Hubert Plociniczak |
cc9fdf |
|
|
Hubert Plociniczak |
cc9fdf |
cd /var/lib/rabbitmq
|
|
Hubert Plociniczak |
cc9fdf |
|
|
Hubert Plociniczak |
cc9fdf |
SCRIPT=`basename $0`
|
|
Hubert Plociniczak |
cc9fdf |
|
|
Hubert Plociniczak |
cc9fdf |
if [ `id -u` = 0 ] ; then
|
|
Hubert Plociniczak |
cc9fdf |
su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
|
|
Hubert Plociniczak |
1b1224 |
elif [ `id -u` = `id -u rabbitmq` ] ; then
|
|
Hubert Plociniczak |
1b1224 |
/usr/lib/rabbitmq/bin/${SCRIPT} "$@"
|
|
Hubert Plociniczak |
cc9fdf |
else
|
|
Hubert Plociniczak |
359031 |
/usr/lib/rabbitmq/bin/${SCRIPT} "$@"
|
|
Hubert Plociniczak |
359031 |
VAL=$?
|
|
Hubert Plociniczak |
359031 |
if [ $VAL -gt 0 ] ; then
|
|
Hubert Plociniczak |
359031 |
echo
|
|
Hubert Plociniczak |
359031 |
echo "Only root or rabbitmq should run ${SCRIPT}"
|
|
Hubert Plociniczak |
359031 |
echo
|
|
Hubert Plociniczak |
359031 |
fi
|
|
Hubert Plociniczak |
359031 |
exit $VAL
|
|
Hubert Plociniczak |
cc9fdf |
fi
|
|
Hubert Plociniczak |
cc9fdf |
|