require 'formula' class Graylog2Server < Formula homepage 'http://www.graylog2.org/' url 'http://download.graylog2.org/graylog2-server/graylog2-server-0.11.0.tar.gz' sha1 '03c94ce8f255a486d13b38c9ebad159588b30bef' depends_on 'elasticsearch' depends_on 'mongodb' def install mv "graylog2.conf.example", "graylog2.conf" inreplace "graylog2.conf" do |s| # Better to use 127.0.0.1 instead of localhost so you # don't need to allow external access to MongoDB. # http://www.eimermusic.com/code/graylog2-on-mac-os-x/ s.gsub! "mongodb_host = localhost", "mongodb_host = 127.0.0.1" s.gsub! "mongodb_useauth = true", "mongodb_useauth = false" s.gsub! "syslog_listen_port = 514", "syslog_listen_port = 8514" end inreplace "bin/graylog2ctl" do |s| s.gsub! "$NOHUP java -jar ../graylog2-server.jar &", "$NOHUP java -jar #{prefix}/graylog2-server.jar -f #{etc}/graylog2.conf -p /tmp/graylog2.pid &" end etc.install "graylog2.conf" prefix.install Dir['*'] end def caveats; <<-EOS.undent In the interest of allowing you to run graylog2-server as a non-root user, the default syslog_listen_port is set to 8514. The config file is located at: #{etc}/graylog2.conf EOS end plist_options :manual => "graylog2ctl start" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments java -jar #{opt_prefix}/graylog2-server.jar -f #{etc}/graylog2.conf -p /tmp/graylog2.pid RunAtLoad KeepAlive WorkingDirectory #{HOMEBREW_PREFIX} StandardErrorPath #{var}/log/graylog2-server/error.log StandardOutPath #{var}/log/graylog2-server/output.log EOS end def test system "#{bin}/graylog2ctl" end end