2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-09-01 15:01:20 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Rabbitmq < Formula
|
2011-08-31 17:17:24 +00:00
|
|
|
homepage 'http://www.rabbitmq.com'
|
2012-12-12 15:21:29 +00:00
|
|
|
url 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-generic-unix-3.0.1.tar.gz'
|
|
|
|
sha1 '6256a589eea964adc7e051945818cb1b63ededc7'
|
2009-09-01 15:01:20 +00:00
|
|
|
|
|
|
|
depends_on 'erlang'
|
2012-09-05 04:04:01 +00:00
|
|
|
depends_on 'simplejson' => :python if MacOS.version == :leopard
|
2009-09-01 15:01:20 +00:00
|
|
|
|
|
|
|
def install
|
2012-05-05 01:46:05 +00:00
|
|
|
# Install the base files
|
|
|
|
prefix.install Dir['*']
|
2009-10-02 09:53:14 +00:00
|
|
|
|
2012-05-05 01:46:05 +00:00
|
|
|
# Setup the lib files
|
2010-09-07 14:24:34 +00:00
|
|
|
(var+'lib/rabbitmq').mkpath
|
|
|
|
(var+'log/rabbitmq').mkpath
|
2009-10-02 09:53:14 +00:00
|
|
|
|
2012-05-05 01:46:05 +00:00
|
|
|
# Replace the SYS_PREFIX for things like rabbitmq-plugins
|
|
|
|
inreplace (sbin + 'rabbitmq-defaults'), 'SYS_PREFIX=${RABBITMQ_HOME}', "SYS_PREFIX=#{HOMEBREW_PREFIX}"
|
|
|
|
|
|
|
|
# Set the RABBITMQ_HOME in rabbitmq-env
|
|
|
|
inreplace (sbin + 'rabbitmq-env'), 'RABBITMQ_HOME="${SCRIPT_DIR}/.."', "RABBITMQ_HOME=#{prefix}"
|
|
|
|
|
|
|
|
# Create the rabbitmq-env.conf file
|
|
|
|
rabbitmq_env_conf = etc+'rabbitmq/rabbitmq-env.conf'
|
|
|
|
rabbitmq_env_conf.write rabbitmq_env unless rabbitmq_env_conf.exist?
|
2009-10-17 19:27:27 +00:00
|
|
|
|
2012-12-12 15:21:29 +00:00
|
|
|
# Enable the management web UI and visualiser
|
2012-05-05 01:46:05 +00:00
|
|
|
enabled_plugins_path = etc+'rabbitmq/enabled_plugins'
|
|
|
|
enabled_plugins_path.write enabled_plugins unless enabled_plugins_path.exist?
|
2012-11-23 16:46:27 +00:00
|
|
|
|
2012-12-12 15:21:29 +00:00
|
|
|
# Extract rabbitmqadmin and install to sbin
|
|
|
|
# use it to generate, then install the bash completion file
|
|
|
|
system ("/usr/bin/unzip", "-qq", "-j", "#{prefix}/plugins/rabbitmq_management-#{version}.ez", "rabbitmq_management-#{version}/priv/www/cli/rabbitmqadmin")
|
2012-11-23 16:46:27 +00:00
|
|
|
sbin.install 'rabbitmqadmin'
|
|
|
|
|
2012-12-12 15:21:29 +00:00
|
|
|
system ("#{sbin}/rabbitmqadmin --bash-completion > rabbitmqadmin.bash")
|
|
|
|
(prefix+'etc/bash_completion.d').install 'rabbitmqadmin.bash'
|
|
|
|
|
2011-04-26 14:56:57 +00:00
|
|
|
end
|
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2012-11-23 16:46:27 +00:00
|
|
|
Management Plugin enabled by default at http://localhost:15672
|
2011-04-26 14:56:57 +00:00
|
|
|
EOS
|
|
|
|
end
|
2012-05-22 01:43:11 +00:00
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def enabled_plugins; <<-EOS.undent
|
2012-05-05 01:46:05 +00:00
|
|
|
[rabbitmq_management,rabbitmq_management_visualiser].
|
|
|
|
EOS
|
|
|
|
end
|
2011-04-26 14:56:57 +00:00
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
def rabbitmq_env; <<-EOS.undent
|
2012-05-05 01:46:05 +00:00
|
|
|
CONFIG_FILE=#{etc}/rabbitmq/rabbitmq
|
|
|
|
NODE_IP_ADDRESS=127.0.0.1
|
2012-05-22 01:43:11 +00:00
|
|
|
NODENAME=rabbit@localhost
|
2012-05-05 01:46:05 +00:00
|
|
|
EOS
|
|
|
|
end
|
2012-05-22 01:43:11 +00:00
|
|
|
|
2012-11-25 15:06:41 +00:00
|
|
|
plist_options :manual => 'rabbitmq-server'
|
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
|
|
|
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>#{plist_name}</string>
|
|
|
|
<key>Program</key>
|
|
|
|
<string>#{opt_prefix}/sbin/rabbitmq-server</string>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
|
|
|
<string>#{`whoami`.chomp}</string>
|
|
|
|
<key>EnvironmentVariables</key>
|
|
|
|
<dict>
|
|
|
|
<!-- need erl in the path -->
|
|
|
|
<key>PATH</key>
|
|
|
|
<string>/usr/local/sbin:/usr/bin:/bin:/usr/local/bin</string>
|
|
|
|
<!-- specify the path to the rabbitmq-env.conf file -->
|
|
|
|
<key>CONF_ENV_FILE</key>
|
|
|
|
<string>#{etc}/rabbitmq/rabbitmq-env.conf</string>
|
|
|
|
</dict>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
2009-09-01 15:01:20 +00:00
|
|
|
end
|
|
|
|
end
|