summaryrefslogtreecommitdiff
path: root/packaging/common
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@lshift.net>2009-09-18 13:05:47 +0100
committerTony Garnock-Jones <tonyg@lshift.net>2009-09-18 13:05:47 +0100
commita95080fdfe8a7d2fdbf25fba6654abc77fd1d2ba (patch)
tree5e17e538b258024f055002cc0761056bdd16882b /packaging/common
parent218f55288615945c9c3dcca7fb862b7b5e5ec2b2 (diff)
parent79b4481a858020c2486f5b561b63d427c61bcf35 (diff)
downloadrabbitmq-server-git-a95080fdfe8a7d2fdbf25fba6654abc77fd1d2ba.tar.gz
merge default into bug21346
Diffstat (limited to 'packaging/common')
-rw-r--r--packaging/common/rabbitmq-asroot-script-wrapper53
-rw-r--r--packaging/common/rabbitmq-script-wrapper31
-rw-r--r--packaging/common/rabbitmq-server.init137
3 files changed, 221 insertions, 0 deletions
diff --git a/packaging/common/rabbitmq-asroot-script-wrapper b/packaging/common/rabbitmq-asroot-script-wrapper
new file mode 100644
index 0000000000..0dd1c0fbda
--- /dev/null
+++ b/packaging/common/rabbitmq-asroot-script-wrapper
@@ -0,0 +1,53 @@
+#!/bin/bash
+## The contents of this file are subject to the Mozilla Public License
+## Version 1.1 (the "License"); you may not use this file except in
+## compliance with the License. You may obtain a copy of the License at
+## http://www.mozilla.org/MPL/
+##
+## Software distributed under the License is distributed on an "AS IS"
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+## License for the specific language governing rights and limitations
+## under the License.
+##
+## The Original Code is RabbitMQ.
+##
+## The Initial Developers of the Original Code are LShift Ltd,
+## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+##
+## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+## Technologies LLC, and Rabbit Technologies Ltd.
+##
+## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+## Ltd. Portions created by Cohesive Financial Technologies LLC are
+## Copyright (C) 2007-2009 Cohesive Financial Technologies
+## LLC. Portions created by Rabbit Technologies Ltd are Copyright
+## (C) 2007-2009 Rabbit Technologies Ltd.
+##
+## All Rights Reserved.
+##
+## Contributor(s): ______________________________________.
+##
+
+# 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
+ /usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}
+else
+ echo -e "\nOnly root should run ${SCRIPT}\n"
+ exit 1
+fi
+
diff --git a/packaging/common/rabbitmq-script-wrapper b/packaging/common/rabbitmq-script-wrapper
index fbb300ace6..94d72f169a 100644
--- a/packaging/common/rabbitmq-script-wrapper
+++ b/packaging/common/rabbitmq-script-wrapper
@@ -1,4 +1,35 @@
#!/bin/sh
+## The contents of this file are subject to the Mozilla Public License
+## Version 1.1 (the "License"); you may not use this file except in
+## compliance with the License. You may obtain a copy of the License at
+## http://www.mozilla.org/MPL/
+##
+## Software distributed under the License is distributed on an "AS IS"
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+## License for the specific language governing rights and limitations
+## under the License.
+##
+## The Original Code is RabbitMQ.
+##
+## The Initial Developers of the Original Code are LShift Ltd,
+## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+##
+## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+## Technologies LLC, and Rabbit Technologies Ltd.
+##
+## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+## Ltd. Portions created by Cohesive Financial Technologies LLC are
+## Copyright (C) 2007-2009 Cohesive Financial Technologies
+## LLC. Portions created by Rabbit Technologies Ltd are Copyright
+## (C) 2007-2009 Rabbit Technologies Ltd.
+##
+## All Rights Reserved.
+##
+## Contributor(s): ______________________________________.
+##
+
# Escape spaces and quotes, because shell is revolting.
for arg in "$@" ; do
# Escape quotes in parameters, so that they're passed through cleanly.
diff --git a/packaging/common/rabbitmq-server.init b/packaging/common/rabbitmq-server.init
new file mode 100644
index 0000000000..e71562f834
--- /dev/null
+++ b/packaging/common/rabbitmq-server.init
@@ -0,0 +1,137 @@
+#!/bin/sh
+#
+# rabbitmq-server RabbitMQ broker
+#
+# chkconfig: - 80 05
+# description: Enable AMQP service provided by RabbitMQ
+#
+
+### BEGIN INIT INFO
+# Provides: rabbitmq-server
+# Required-Start: $remote_fs $network
+# Required-Stop: $remote_fs $network
+# Default-Start:
+# Default-Stop:
+# Description: RabbitMQ broker
+# Short-Description: Enable AMQP service provided by RabbitMQ broker
+### END INIT INFO
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DAEMON=/usr/sbin/rabbitmq-multi
+NAME=rabbitmq-server
+DESC=rabbitmq-server
+USER=rabbitmq
+NODE_COUNT=1
+ROTATE_SUFFIX=
+
+DEFAULTS_FILE= # This is filled in when building packages
+LOCK_FILE= # This is filled in when building packages
+
+test -x $DAEMON || exit 0
+
+# Include rabbitmq defaults if available
+if [ -f "$DEFAULTS_FILE" ] ; then
+ . $DEFAULTS_FILE
+fi
+
+RETVAL=0
+set -e
+
+start_rabbitmq () {
+ set +e
+ $DAEMON start_all ${NODE_COUNT} > /var/log/rabbitmq/startup_log 2> /var/log/rabbitmq/startup_err
+ case "$?" in
+ 0)
+ echo SUCCESS
+ [ -n "$LOCK_FILE" ] && touch $LOCK_FILE
+ RETVAL=0
+ ;;
+ 1)
+ echo TIMEOUT - check /var/log/rabbitmq/startup_\{log,err\}
+ RETVAL=1
+ ;;
+ *)
+ echo FAILED - check /var/log/rabbitmq/startup_log, _err
+ RETVAL=1
+ ;;
+ esac
+ set -e
+}
+
+stop_rabbitmq () {
+ set +e
+ status_rabbitmq quiet
+ if [ $RETVAL = 0 ] ; then
+ $DAEMON stop_all > /var/log/rabbitmq/shutdown_log 2> /var/log/rabbitmq/shutdown_err
+ RETVAL=$?
+ if [ $RETVAL = 0 ] ; then
+ # Try to stop epmd if run by the rabbitmq user
+ pkill -u rabbitmq epmd || :
+ [ -n "$LOCK_FILE" ] && rm -rf $LOCK_FILE
+ else
+ echo FAILED - check /var/log/rabbitmq/shutdown_log, _err
+ fi
+ else
+ echo No nodes running
+ RETVAL=0
+ fi
+ set -e
+}
+
+status_rabbitmq() {
+ set +e
+ if [ "$1" != "quiet" ] ; then
+ $DAEMON status 2>&1
+ else
+ $DAEMON status > /dev/null 2>&1
+ fi
+ if [ $? != 0 ] ; then
+ RETVAL=1
+ fi
+ set -e
+}
+
+rotate_logs_rabbitmq() {
+ set +e
+ $DAEMON rotate_logs ${ROTATE_SUFFIX}
+ if [ $? != 0 ] ; then
+ RETVAL=1
+ fi
+ set -e
+}
+
+restart_rabbitmq() {
+ stop_rabbitmq
+ start_rabbitmq
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ start_rabbitmq
+ echo "$NAME."
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ stop_rabbitmq
+ echo "$NAME."
+ ;;
+ status)
+ status_rabbitmq
+ ;;
+ rotate-logs)
+ echo -n "Rotating log files for $DESC: "
+ rotate_logs_rabbitmq
+ ;;
+ force-reload|reload|restart|condrestart|try-restart)
+ echo -n "Restarting $DESC: "
+ restart_rabbitmq
+ echo "$NAME."
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
+ RETVAL=1
+ ;;
+esac
+
+exit $RETVAL