Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2010
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.54 KB | None | 0 0
  1. require 'formula'
  2. require 'hardware'
  3.  
  4. class Mongodb < Formula
  5.   homepage 'http://www.mongodb.org/'
  6.  
  7.   if Hardware.is_64_bit? and not ARGV.include? '--32bit'
  8.     url 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.6.1.tgz'
  9.     md5 '19697b489a0c038aad9a3ed3e546a19a'
  10.     version '1.6.1-x86_64'
  11.   else
  12.     url 'http://fastdl.mongodb.org/osx/mongodb-osx-i386-1.6.1.tgz'
  13.     md5 'eefd7f72b34c5f9bd1ebd1a0a288dc16'
  14.     version '1.6.1-i386'
  15.   end
  16.  
  17.   skip_clean :all
  18.  
  19.   def options
  20.     [['--32bit', 'Install the 32-bit version.']]
  21.   end
  22.  
  23.   def install
  24.     # Copy the prebuilt binaries to prefix
  25.     prefix.install Dir['*']
  26.  
  27.     # Create the data and log directories under /var
  28.     (var+'mongodb').mkpath
  29.     (var+'log/mongodb').mkpath
  30.  
  31.     # Write the configuration files and launchd script
  32.     (prefix+'mongod.conf').write mongodb_conf
  33.     (prefix+'org.mongodb.mongod.plist').write startup_plist
  34.   end
  35.  
  36.   def caveats; <<-EOS
  37. If this is your first install, automatically load on login with:
  38.     cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents
  39.     launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  40.  
  41. If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
  42.     launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  43.     cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents
  44.     launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  45.  
  46. Or start it manually:
  47.     mongod run --config #{prefix}/mongod.conf
  48. EOS
  49.   end
  50.  
  51.   def mongodb_conf
  52.     return <<-EOS
  53. # Store data in #{var}/mongodb instead of the default /data/db
  54. dbpath = #{var}/mongodb
  55.  
  56. # Only accept local connections
  57. bind_ip = 127.0.0.1
  58. EOS
  59.   end
  60.  
  61.   def startup_plist
  62.     return <<-EOS
  63. <?xml version="1.0" encoding="UTF-8"?>
  64. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  65. <plist version="1.0">
  66. <dict>
  67.   <key>Label</key>
  68.   <string>org.mongodb.mongod</string>
  69.   <key>ProgramArguments</key>
  70.   <array>
  71.     <string>#{bin}/mongod</string>
  72.     <string>run</string>
  73.     <string>--config</string>
  74.     <string>#{prefix}/mongod.conf</string>
  75.   </array>
  76.   <key>RunAtLoad</key>
  77.   <true/>
  78.   <key>KeepAlive</key>
  79.   <true/>
  80.   <key>UserName</key>
  81.   <string>#{`whoami`.chomp}</string>
  82.   <key>WorkingDirectory</key>
  83.   <string>#{HOMEBREW_PREFIX}</string>
  84.   <key>StandardErrorPath</key>
  85.   <string>#{var}/log/mongodb/output.log</string>
  86.   <key>StandardOutPath</key>
  87.   <string>#{var}/log/mongodb/output.log</string>
  88. </dict>
  89. </plist>
  90. EOS
  91.   end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement