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-12-28 20:46:22 +00:00
|
|
|
aka :mongo
|
|
|
|
|
2009-11-06 19:34:54 +00:00
|
|
|
if Hardware.is_64_bit? and not ARGV.include? '--32bit'
|
2010-05-25 15:07:25 +00:00
|
|
|
url 'http://downloads.mongodb.org/osx/mongodb-osx-x86_64-1.4.3.tgz'
|
|
|
|
md5 '8bca0e966f2de3d66bb6faac3bbd041c'
|
|
|
|
version '1.4.3-x86_64'
|
2009-10-27 20:20:28 +00:00
|
|
|
else
|
2010-05-25 15:07:25 +00:00
|
|
|
url 'http://downloads.mongodb.org/osx/mongodb-osx-i386-1.4.3.tgz'
|
|
|
|
md5 '8a264838a950043682718c330896ecbe'
|
|
|
|
version '1.4.3-i386'
|
2009-11-06 19:34:54 +00:00
|
|
|
end
|
2009-12-28 20:46:22 +00:00
|
|
|
|
2009-11-06 19:34:54 +00:00
|
|
|
def skip_clean? path
|
|
|
|
true
|
2009-10-27 20:20:28 +00:00
|
|
|
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
|
2009-09-05 22:14:47 +00:00
|
|
|
system "cp -prv * #{prefix}"
|
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
|
|
|
|
end
|