Blame rabbitmq-asroot-script-wrapper

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