summaryrefslogtreecommitdiffstats
path: root/rabbitmq-script-wrapper
blob: 296a77d19c50429596000167f0932204de34ed44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Escape spaces and quotes, because shell is revolting.
for arg in "$@" ; do
	# Escape quotes in parameters, so that they're passed through cleanly.
	arg=$(sed -e 's/"/\\"/' <<-END
		$arg
		END
	)
	CMDLINE="${CMDLINE} \"${arg}\""
done

cd /var/lib/rabbitmq

SCRIPT=`basename $0`

if [ `id -u` = 0 ] ; then
    su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
else
    /usr/lib/rabbitmq/bin/${SCRIPT}
    echo -e "\nOnly root should run ${SCRIPT}\n"
    exit 1
fi