summaryrefslogtreecommitdiff
path: root/packaging/debs/Debian/debian/rabbitmqctl_wrapper
blob: d53a6ca9c61b57921ccc2c43119bb987b7fef23f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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 /

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