summaryrefslogtreecommitdiff
path: root/packaging/common
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert@lshift.net>2009-02-04 01:02:39 +0000
committerHubert Plociniczak <hubert@lshift.net>2009-02-04 01:02:39 +0000
commit7424a912b19ec6e2aaf6a03d291aedc4a9aaa8fe (patch)
tree0b6e793eb7d3b0a7a118682ba4cc1f9adb6376f7 /packaging/common
parent6f0e6d40c30079764b4e4e7472883d8abb9ff7e9 (diff)
downloadrabbitmq-server-git-7424a912b19ec6e2aaf6a03d291aedc4a9aaa8fe.tar.gz
Provide common wrapper script that is used by all commands and requires root permissions to function normally.
Also added PATH variable in init.d and use new wrappers.
Diffstat (limited to 'packaging/common')
-rw-r--r--packaging/common/rabbitmq-script-wrapper23
1 files changed, 23 insertions, 0 deletions
diff --git a/packaging/common/rabbitmq-script-wrapper b/packaging/common/rabbitmq-script-wrapper
new file mode 100644
index 0000000000..78ad528c1d
--- /dev/null
+++ b/packaging/common/rabbitmq-script-wrapper
@@ -0,0 +1,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 /
+
+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
+