aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorMax Howell2012-09-13 14:07:09 -0400
committerMax Howell2012-09-13 14:08:14 -0400
commit73f9ea5e688c592da50b638bf722334a66877434 (patch)
treeb35b73c4d0628d0548049044076340c0c903939a /Library/Formula
parentaa52468488f696685ca0606c6544bc271c02d16e (diff)
downloadhomebrew-73f9ea5e688c592da50b638bf722334a66877434.tar.bz2
Sophisticated mongo launchd instructions
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/mongodb.rb39
1 files changed, 25 insertions, 14 deletions
diff --git a/Library/Formula/mongodb.rb b/Library/Formula/mongodb.rb
index e6287ea3b..699f0314f 100644
--- a/Library/Formula/mongodb.rb
+++ b/Library/Formula/mongodb.rb
@@ -27,6 +27,7 @@ class Mongodb < Formula
(prefix+'mongod.conf').write mongodb_conf
# Homebrew: it just works.
+ # NOTE plist updated to use prefix/mongodb!
mv (sh = bin/'mongod'), prefix
sh.write <<-EOS.undent
#!/usr/bin/env ruby
@@ -41,20 +42,30 @@ class Mongodb < Formula
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
- ln -s #{plist_path} ~/Library/LaunchAgents/
- launchctl load -w ~/Library/LaunchAgents/#{bn}
+ la = Pathname.new("#{ENV['HOME']}/Library/LaunchAgents")
+ prettypath = "~/Library/LaunchAgents/#{bn}"
+ domain = plist_path.basename('.plist')
+ load = "launchctl load -w #{prettypath}"
+ s = []
- If this is an upgrade and you already have the plist loaded:
- launchctl unload -w ~/Library/LaunchAgents/#{bn}
- launchctl load -w ~/Library/LaunchAgents/#{bn}
-
- Or just start it manually:
- mongod
- EOS
+ # we readlink because this path probably doesn't exist since caveats
+ # occurs before the link step of installation
+ if not (la/bn).file?
+ s << "To have launchd start #{name} at login:"
+ s << " mkdir -p ~/Library/LaunchAgents" unless la.directory?
+ s << " ln -s #{HOMEBREW_PREFIX}/opt/#{name}/*.plist ~/Library/LaunchAgents/"
+ s << "Then to load #{name} now:"
+ s << " #{load}"
+ s << "Or, if you don't want/need launchctl, you can just run:"
+ s << " mongod"
+ elsif Kernel.system "/bin/launchctl list #{domain} &>/dev/null"
+ s << "You should reload #{name}:"
+ s << " launchctl unload -w #{prettypath}"
+ s << " #{load}"
+ else
+ s << "To load #{name}:"
+ s << " #{load}"
+ end
end
def mongodb_conf; <<-EOS.undent
@@ -80,7 +91,7 @@ class Mongodb < Formula
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
- <string>#{HOMEBREW_PREFIX}/bin/mongod</string>
+ <string>#{opt_prefix}/mongod</string>
<string>run</string>
<string>--config</string>
<string>#{etc}/mongod.conf</string>