From 7a494e8d4dce785df58a663b54eaa84b20436e89 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 11 Sep 2012 03:32:10 -0400 Subject: Make mongod just work Hopefully this is safe. I ran a full db against it, everything seemed fine to me. Homebrew should "just work" no remembering to specify `--config foo`, that's just lame sauce. Also cleaned up the caveats and removed the `skip_clean: all`.--- Library/Formula/mongodb.rb | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'Library/Formula') diff --git a/Library/Formula/mongodb.rb b/Library/Formula/mongodb.rb index 58c3a1096..e6287ea3b 100644 --- a/Library/Formula/mongodb.rb +++ b/Library/Formula/mongodb.rb @@ -15,8 +15,6 @@ class Mongodb < Formula option '32-bit' - skip_clean :all - def install # Copy the prebuilt binaries to prefix prefix.install Dir['*'] @@ -28,25 +26,34 @@ class Mongodb < Formula # Write the configuration files (prefix+'mongod.conf').write mongodb_conf + # Homebrew: it just works. + mv (sh = bin/'mongod'), prefix + sh.write <<-EOS.undent + #!/usr/bin/env ruby + ARGV << '--config' << '#{etc}/mongod.conf' unless ARGV.include? '--config' + exec "#{prefix}/mongod", *ARGV + EOS + sh.chmod 0755 + # copy the config file to etc if this is the first install. etc.install prefix+'mongod.conf' unless File.exists? etc+"mongod.conf" end - def caveats; <<-EOS.undent + def caveats + bn = plist_path.basename + plist_path = "#{HOMEBREW_PREFIX}/opt/#{name}/*.plist" + <<-EOS.undent If this is your first install, automatically load on login with: mkdir -p ~/Library/LaunchAgents - cp #{plist_path} ~/Library/LaunchAgents/ - launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} - - If this is an upgrade and you already have the #{plist_path.basename} loaded: - launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename} - cp #{plist_path} ~/Library/LaunchAgents/ - launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} + ln -s #{plist_path} ~/Library/LaunchAgents/ + launchctl load -w ~/Library/LaunchAgents/#{bn} - Or start it manually: - mongod run --config #{etc}/mongod.conf + If this is an upgrade and you already have the plist loaded: + launchctl unload -w ~/Library/LaunchAgents/#{bn} + launchctl load -w ~/Library/LaunchAgents/#{bn} - The launchctl plist above expects the config file to be at #{etc}/mongod.conf. + Or just start it manually: + mongod EOS end -- cgit v1.2.3