2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-11-12 00:17:00 +00:00
|
|
|
require 'hardware'
|
2009-09-05 22:14:47 +00:00
|
|
|
|
|
|
|
class Mongodb <Formula
|
2009-10-01 20:18:01 +00:00
|
|
|
homepage 'http://www.mongodb.org/'
|
2009-10-27 20:20:28 +00:00
|
|
|
|
2009-11-06 19:34:54 +00:00
|
|
|
if Hardware.is_64_bit? and not ARGV.include? '--32bit'
|
2010-09-23 18:47:19 +00:00
|
|
|
url 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.6.3.tgz'
|
|
|
|
md5 'da6a3a1e52e2ec7134a75b857ad540e8'
|
|
|
|
version '1.6.3-x86_64'
|
2009-10-27 20:20:28 +00:00
|
|
|
else
|
2010-09-23 18:47:19 +00:00
|
|
|
url 'http://fastdl.mongodb.org/osx/mongodb-osx-i386-1.6.3.tgz'
|
|
|
|
md5 '6f8244f0bc3a842d16f92e5f7fa33e98'
|
|
|
|
version '1.6.3-i386'
|
2009-11-06 19:34:54 +00:00
|
|
|
end
|
2009-12-28 20:46:22 +00:00
|
|
|
|
2010-04-07 05:58:35 +00:00
|
|
|
skip_clean :all
|
2009-09-05 22:14:47 +00:00
|
|
|
|
2010-08-10 20:05:20 +00:00
|
|
|
def options
|
|
|
|
[['--32bit', 'Install the 32-bit version.']]
|
|
|
|
end
|
|
|
|
|
2009-09-05 22:14:47 +00:00
|
|
|
def install
|
2009-12-28 20:46:22 +00:00
|
|
|
# Copy the prebuilt binaries to prefix
|
2010-04-07 05:58:35 +00:00
|
|
|
prefix.install Dir['*']
|
2009-12-28 20:46:22 +00:00
|
|
|
|
|
|
|
# Create the data and log directories under /var
|
|
|
|
(var+'mongodb').mkpath
|
|
|
|
(var+'log/mongodb').mkpath
|
|
|
|
|
|
|
|
# Write the configuration files and launchd script
|
|
|
|
(prefix+'mongod.conf').write mongodb_conf
|
|
|
|
(prefix+'org.mongodb.mongod.plist').write startup_plist
|
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS
|
2010-05-09 00:59:07 +00:00
|
|
|
If this is your first install, automatically load on login with:
|
|
|
|
cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
|
|
|
|
|
|
|
|
If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
|
|
|
|
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
|
|
|
|
cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
|
2009-12-28 20:46:22 +00:00
|
|
|
|
|
|
|
Or start it manually:
|
2009-12-31 04:09:17 +00:00
|
|
|
mongod run --config #{prefix}/mongod.conf
|
2009-12-28 20:46:22 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def mongodb_conf
|
|
|
|
return <<-EOS
|
|
|
|
# Store data in #{var}/mongodb instead of the default /data/db
|
|
|
|
dbpath = #{var}/mongodb
|
|
|
|
|
|
|
|
# Only accept local connections
|
|
|
|
bind_ip = 127.0.0.1
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def startup_plist
|
|
|
|
return <<-EOS
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>org.mongodb.mongod</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{bin}/mongod</string>
|
|
|
|
<string>run</string>
|
|
|
|
<string>--config</string>
|
|
|
|
<string>#{prefix}/mongod.conf</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
2010-01-16 15:48:56 +00:00
|
|
|
<string>#{`whoami`.chomp}</string>
|
2009-12-28 20:46:22 +00:00
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{HOMEBREW_PREFIX}</string>
|
|
|
|
<key>StandardErrorPath</key>
|
|
|
|
<string>#{var}/log/mongodb/output.log</string>
|
|
|
|
<key>StandardOutPath</key>
|
|
|
|
<string>#{var}/log/mongodb/output.log</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
2009-09-05 22:14:47 +00:00
|
|
|
end
|
2010-08-17 21:20:14 +00:00
|
|
|
end
|