rabbitmq-script-wrapper 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  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 at
  5. ## http://www.mozilla.org/MPL/
  6. ##
  7. ## Software distributed under the License is distributed on an "AS IS"
  8. ## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. ## License for the specific language governing rights and limitations
  10. ## under the License.
  11. ##
  12. ## The Original Code is RabbitMQ.
  13. ##
  14. ## The Initial Developers of the Original Code are LShift Ltd,
  15. ## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
  16. ##
  17. ## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
  18. ## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
  19. ## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
  20. ## Technologies LLC, and Rabbit Technologies Ltd.
  21. ##
  22. ## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
  23. ## Ltd. Portions created by Cohesive Financial Technologies LLC are
  24. ## Copyright (C) 2007-2009 Cohesive Financial Technologies
  25. ## LLC. Portions created by Rabbit Technologies Ltd are Copyright
  26. ## (C) 2007-2009 Rabbit Technologies Ltd.
  27. ##
  28. ## All Rights Reserved.
  29. ##
  30. ## Contributor(s): ______________________________________.
  31. ##
  32. # Escape spaces and quotes, because shell is revolting.
  33. CMDLINE=""
  34. for arg in "$@" ; do
  35. # Escape quotes in parameters, so that they're passed through cleanly.
  36. arg=$(sed -e 's/"/\\"/g' <<-END
  37. $arg
  38. END
  39. )
  40. CMDLINE="${CMDLINE} \"${arg}\""
  41. done
  42. cd /var/lib/rabbitmq
  43. SCRIPT=`basename $0`
  44. if [ `id -u` = 0 ] ; then
  45. su rabbitmq -s /bin/sh -c "/usr/libexec/rabbitmq/${SCRIPT} ${CMDLINE}"
  46. else
  47. /usr/libexec/rabbitmq/${SCRIPT}
  48. echo -e "\nOnly root should run ${SCRIPT}\n"
  49. exit 1
  50. fi