Detect util-linux version of runuser

Alternative is to always use runuser invocation in else clause.

Fixes #44.
[#150221349]
This commit is contained in:
Luke Bakken 2017-09-08 17:41:10 -07:00 committed by Jean-Sébastien Pédron
parent 617d1603d6
commit f410369672
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 12 additions and 1 deletions

View File

@ -77,7 +77,18 @@ exec_script_as_rabbitmq() {
exec_script_as_root() {
if [ -x /sbin/runuser ]
then
exec /sbin/runuser -u rabbitmq -- "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
# TODO:
# At some point all of the RabbitMQ supported distributions will be using
# the util-linux version of /sbin/runuser, as it has been removed from GNU
# coreutils as of 2012. At that point the first clause of the following
# if statement can become the only statement used and the if/then
# removed
if /sbin/runuser --version | grep -qF util-linux
then
exec /sbin/runuser -u rabbitmq -- "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
else
exec /sbin/runuser -s /bin/sh -- rabbitmq "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"
fi
elif [ -x /bin/su ]
then
exec /bin/su -s /bin/sh rabbitmq -- "/usr/lib/rabbitmq/bin/$SCRIPT" "$@"