require 'formula' class Rabbitmq < Formula homepage 'http://www.rabbitmq.com' url 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.4/rabbitmq-server-mac-standalone-3.3.4.tar.gz' sha1 '4493b05c74f3f6660f7ff1665d5774004c53b453' bottle do sha1 "963a51963f91ecd8dd5d137af353dd11a0fdab0b" => :mavericks sha1 "0aac040dfa849dae74548187f184cf7c3becdd59" => :mountain_lion sha1 "09162a428bbe451466b1d12e9505e8d932592d40" => :lion end depends_on 'simplejson' => :python if MacOS.version <= :leopard def install # Install the base files prefix.install Dir['*'] # Setup the lib files (var+'lib/rabbitmq').mkpath (var+'log/rabbitmq').mkpath # Correct SYS_PREFIX for things like rabbitmq-plugins inreplace sbin/'rabbitmq-defaults' do |s| s.gsub! 'SYS_PREFIX=${RABBITMQ_HOME}', "SYS_PREFIX=#{HOMEBREW_PREFIX}" s.gsub! 'CLEAN_BOOT_FILE="${SYS_PREFIX}', "CLEAN_BOOT_FILE=\"#{prefix}" s.gsub! 'SASL_BOOT_FILE="${SYS_PREFIX}', "SASL_BOOT_FILE=\"#{prefix}" end # Set 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? # Enable plugins - management web UI and visualiser; STOMP, MQTT, AMQP 1.0 protocols enabled_plugins_path = etc+'rabbitmq/enabled_plugins' enabled_plugins_path.write '[rabbitmq_management,rabbitmq_management_visualiser,rabbitmq_stomp,rabbitmq_amqp1_0,rabbitmq_mqtt].' unless enabled_plugins_path.exist? # 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" sbin.install 'rabbitmqadmin' (sbin/'rabbitmqadmin').chmod 0755 (bash_completion/'rabbitmqadmin.bash').write `#{sbin}/rabbitmqadmin --bash-completion` end def caveats; <<-EOS.undent Management Plugin enabled by default at http://localhost:15672 EOS end def rabbitmq_env; <<-EOS.undent CONFIG_FILE=#{etc}/rabbitmq/rabbitmq NODE_IP_ADDRESS=127.0.0.1 NODENAME=rabbit@localhost EOS end plist_options :manual => 'rabbitmq-server' def plist; <<-EOS.undent Label #{plist_name} Program #{opt_sbin}/rabbitmq-server RunAtLoad EnvironmentVariables PATH /usr/local/sbin:/usr/bin:/bin:/usr/local/bin CONF_ENV_FILE #{etc}/rabbitmq/rabbitmq-env.conf EOS end end