Blame rabbitmq-script-wrapper

Hubert Plociniczak cc9fdf
#!/bin/bash
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 cc9fdf
	arg=$(sed -e 's/"/\\"/' <<-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 cc9fdf
else
Hubert Plociniczak cc9fdf
    /usr/lib/rabbitmq/bin/${SCRIPT}
Hubert Plociniczak cc9fdf
    echo -e "\nOnly root should run ${SCRIPT}\n"
Hubert Plociniczak cc9fdf
    exit 1
Hubert Plociniczak cc9fdf
fi
Hubert Plociniczak cc9fdf