Skip to content
This repository
Browse code

Add and use plist helper methods

These will be used to unify the label namespaces in embedded plists,
i.e. 'homebrew.mxcl.<formula>'.

plist_path returns the full path to a plist file located at the top
level of the keg; plist_path.basename can be used if just the filename
is needed.

c.f. #9346.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
  • Loading branch information...
commit b5a5217ba3117dfbfcad63532c2054d83d3249c0 1 parent 95e379f
Jack Nagel authored December 30, 2011
10  Library/Formula/cassandra.rb
@@ -31,15 +31,15 @@ def install
31 31
     prefix.install Dir["*.txt"] + Dir["{bin,interface,javadoc,lib/licenses}"]
32 32
     prefix.install Dir["lib/*.jar"]
33 33
 
34  
-    (prefix+'org.apache.cassandra.plist').write startup_plist
35  
-    (prefix+'org.apache.cassandra.plist').chmod 0644
  34
+    plist_path.write startup_plist
  35
+    plist_path.chmod 0644
36 36
   end
37 37
 
38 38
   def caveats; <<-EOS.undent
39 39
     If this is your first install, automatically load on login with:
40 40
       mkdir -p ~/Library/LaunchAgents
41  
-      cp #{prefix}/org.apache.cassandra.plist ~/Library/LaunchAgents/
42  
-      launchctl load -w ~/Library/LaunchAgents/org.apache.cassandra.plist
  41
+      cp #{plist_path} ~/Library/LaunchAgents/
  42
+      launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
43 43
     EOS
44 44
   end
45 45
 
@@ -52,7 +52,7 @@ def startup_plist; <<-EOPLIST
52 52
     <true/>
53 53
 
54 54
     <key>Label</key>
55  
-    <string>org.apache.cassandra</string>
  55
+    <string>#{plist_name}</string>
56 56
 
57 57
     <key>ProgramArguments</key>
58 58
     <array>
12  Library/Formula/couchdb-lucene.rb
@@ -15,16 +15,16 @@ def install
15 15
     system "mv couchdb-lucene-#{version}/* #{prefix}"
16 16
 
17 17
     (etc + "couchdb/local.d/couchdb-lucene.ini").write ini_file
18  
-    (prefix+"couchdb-lucene.plist").write plist_file
19  
-    (prefix+"couchdb-lucene.plist").chmod 0644
  18
+    plist_path.write startup_plist
  19
+    plist_path.chmod 0644
20 20
   end
21 21
 
22 22
   def caveats; <<-EOS.undent
23 23
     You can enable couchdb-lucene to automatically load on login with:
24 24
 
25 25
       mkdir -p ~/Library/LaunchAgents
26  
-      cp "#{prefix}/couchdb-lucene.plist" ~/Library/LaunchAgents/
27  
-      launchctl load -w ~/Library/LaunchAgents/couchdb-lucene.plist
  26
+      cp "#{plist_path}" ~/Library/LaunchAgents/
  27
+      launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
28 28
 
29 29
     Or start it manually with:
30 30
       #{bin}/run
@@ -44,7 +44,7 @@ def ini_file
44 44
 EOS
45 45
   end
46 46
 
47  
-  def plist_file
  47
+  def startup_plist
48 48
     return <<-EOS
49 49
 <?xml version="1.0" encoding="UTF-8"?>
50 50
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
@@ -52,7 +52,7 @@ def plist_file
52 52
 <plist version="1.0">
53 53
   <dict>
54 54
     <key>Label</key>
55  
-    <string>couchdb-lucene</string>
  55
+    <string>#{plist_name}</string>
56 56
     <key>EnvironmentVariables</key>
57 57
     <dict>
58 58
       <key>HOME</key>
18  Library/Formula/ddclient.rb
@@ -36,8 +36,8 @@ def install
36 36
     (var + 'run/ddclient').mkpath
37 37
 
38 38
     # Write the launchd script
39  
-    (prefix + 'org.ddclient.plist').write startup_plist
40  
-    (prefix + 'org.ddclient.plist').chmod 0644
  39
+    plist_path.write startup_plist
  40
+    plist_path.chmod 0644
41 41
   end
42 42
 
43 43
   def caveats; <<-EOS
@@ -51,21 +51,21 @@ def caveats; <<-EOS
51 51
 
52 52
 2) Install the launchd item in /Library/LaunchDaemons, like so:
53 53
 
54  
-   sudo cp -vf #{prefix}/org.ddclient.plist /Library/LaunchDaemons/
55  
-   sudo chown -v root:wheel /Library/LaunchDaemons/org.ddclient.plist
  54
+   sudo cp -vf #{plist_path} /Library/LaunchDaemons/
  55
+   sudo chown -v root:wheel /Library/LaunchDaemons/#{plist_path.basename}
56 56
 
57 57
 3) Start the daemon using:
58 58
 
59  
-  sudo launchctl load /Library/LaunchDaemons/org.ddclient.plist
  59
+  sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
60 60
 
61 61
 The next reboot of the system will automatically start ddclient.
62 62
 
63 63
 You can adjust the execution interval by changing the value of
64  
-StartInterval (in seconds) in /Library/LaunchDaemons/org.ddclient.plist,
  64
+StartInterval (in seconds) in /Library/LaunchDaemons/#{plist_path.basename},
65 65
 and then
66 66
 
67  
-   sudo launchctl unload /Library/LaunchDaemons/org.ddclient.plist
68  
-   sudo launchctl load /Library/LaunchDaemons/org.ddclient.plist
  67
+   sudo launchctl unload /Library/LaunchDaemons/#{plist_path.basename}
  68
+   sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
69 69
 EOS
70 70
   end
71 71
 
@@ -76,7 +76,7 @@ def startup_plist
76 76
 <plist version="1.0">
77 77
 <dict>
78 78
   <key>Label</key>
79  
-  <string>org.ddclient</string>
  79
+  <string>#{plist_name}</string>
80 80
   <key>ProgramArguments</key>
81 81
   <array>
82 82
     <string>#{HOMEBREW_PREFIX}/sbin/ddclient</string>
9  Library/Formula/denyhosts.rb
@@ -43,9 +43,8 @@ def install
43 43
     ln_s libexec + 'denyhosts.py', sbin + 'denyhosts'
44 44
     ln_s libexec + 'daemon-control', sbin + 'daemon-control'
45 45
 
46  
-    plist = prefix + 'org.denyhosts.cron.plist'
47  
-    plist.write cron_plist
48  
-    plist.chmod 0644
  46
+    plist_path.write cron_plist
  47
+    plist_path.chmod 0644
49 48
   end
50 49
 
51 50
   def cron_plist
@@ -55,7 +54,7 @@ def cron_plist
55 54
       <plist version="1.0">
56 55
       <dict>
57 56
         <key>Label</key>
58  
-        <string>org.denyhosts.cron</string>
  57
+        <string>#{plist_name}</string>
59 58
         <key>ProgramArguments</key>
60 59
         <array>
61 60
           <string>#{HOMEBREW_PREFIX}/sbin/denyhosts</string>
@@ -83,7 +82,7 @@ def caveats
83 82
       /etc/hosts.deny every 10 minutes. It will need to be run by the user that
84 83
       owns /etc/hosts.deny, usually root, and can be set to load at startup
85 84
       via:
86  
-        sudo cp #{prefix}/org.denyhosts.cron.plist /Library/LaunchDaemons/
  85
+        sudo cp #{plist_path} /Library/LaunchDaemons/
87 86
 
88 87
     EOS
89 88
   end
10  Library/Formula/dnsmasq.rb
@@ -31,8 +31,8 @@ def install
31 31
     system "make install PREFIX=#{prefix}"
32 32
 
33 33
     prefix.install "dnsmasq.conf.example"
34  
-    (prefix + "uk.org.thekelleys.dnsmasq.plist").write startup_plist
35  
-    (prefix + "uk.org.thekelleys.dnsmasq.plist").chmod 0644
  34
+    plist_path.write startup_plist
  35
+    plist_path.chmod 0644
36 36
   end
37 37
 
38 38
   def caveats; <<-EOS.undent
@@ -44,8 +44,8 @@ def caveats; <<-EOS.undent
44 44
     To load dnsmasq automatically on startup, install and load the provided launchd
45 45
     item as follows:
46 46
 
47  
-      sudo cp #{prefix}/uk.org.thekelleys.dnsmasq.plist /Library/LaunchDaemons
48  
-      sudo launchctl load -w /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
  47
+      sudo cp #{plist_path} /Library/LaunchDaemons
  48
+      sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
49 49
     EOS
50 50
   end
51 51
 
@@ -55,7 +55,7 @@ def startup_plist; <<-EOS.undent
55 55
     <plist version="1.0">
56 56
       <dict>
57 57
         <key>Label</key>
58  
-        <string>uk.org.thekelleys.dnsmasq</string>
  58
+        <string>#{plist_name}</string>
59 59
         <key>ProgramArguments</key>
60 60
         <array>
61 61
           <string>#{HOMEBREW_PREFIX}/sbin/dnsmasq</string>
6  Library/Formula/dovecot.rb
@@ -24,13 +24,13 @@ def caveats; <<-EOS
24 24
 
25 25
 2) If required by the configuration above, create a dovecot user and group
26 26
 
27  
-3) possibly create a launchd item in /Library/LaunchDaemons/org.dovecot.plist, like so:
  27
+3) possibly create a launchd item in /Library/LaunchDaemons/#{plist_path.basename}, like so:
28 28
 <?xml version="1.0" encoding="UTF-8"?>
29 29
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
30 30
 <plist version="1.0">
31 31
 <dict>
32 32
         <key>Label</key>
33  
-        <string>org.dovecot</string>
  33
+        <string>#{plist_name}</string>
34 34
         <key>OnDemand</key>
35 35
         <false/>
36 36
         <key>ProgramArguments</key>
@@ -46,7 +46,7 @@ def caveats; <<-EOS
46 46
 </plist>
47 47
 
48 48
 Source: http://wiki.dovecot.org/LaunchdInstall
49  
-4) start the server using: sudo launchctl load /Library/LaunchDaemons/org.dovecot.plist
  49
+4) start the server using: sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
50 50
     EOS
51 51
   end
52 52
 end
20  Library/Formula/elasticsearch.rb
@@ -48,24 +48,24 @@ def install
48 48
     end
49 49
 
50 50
     # Write .plist file for `launchd`
51  
-    (prefix+'org.elasticsearch.plist').write startup_plist
52  
-    (prefix+'org.elasticsearch.plist').chmod 0644
  51
+    plist_path.write startup_plist
  52
+    plist_path.chmod 0644
53 53
   end
54 54
 
55 55
   def caveats
56 56
     <<-EOS.undent
57 57
     If this is your first install, automatically load ElasticSearch on login with:
58 58
         mkdir -p ~/Library/LaunchAgents
59  
-        ln -nfs #{prefix}/org.elasticsearch.plist ~/Library/LaunchAgents/
60  
-        launchctl load -wF ~/Library/LaunchAgents/org.elasticsearch.plist
  59
+        ln -nfs #{plist_path} ~/Library/LaunchAgents/
  60
+        launchctl load -wF ~/Library/LaunchAgents/#{plist_path.basename}
61 61
 
62  
-    If this is an upgrade and you already have the org.elasticsearch.plist loaded:
63  
-        launchctl unload -w ~/Library/LaunchAgents/org.elasticsearch.plist
64  
-        ln -nfs #{prefix}/org.elasticsearch.plist ~/Library/LaunchAgents/
65  
-        launchctl load -wF ~/Library/LaunchAgents/org.elasticsearch.plist
  62
+    If this is an upgrade and you already have the #{plist_path} loaded:
  63
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  64
+        ln -nfs #{plist_path} ~/Library/LaunchAgents/
  65
+        launchctl load -wF ~/Library/LaunchAgents/#{plist_path.basename}
66 66
 
67 67
     To stop the ElasticSearch daemon:
68  
-        launchctl unload -wF ~/Library/LaunchAgents/org.elasticsearch.plist
  68
+        launchctl unload -wF ~/Library/LaunchAgents/#{plist_path.basename}
69 69
 
70 70
     To start ElasticSearch manually:
71 71
         elasticsearch -f -D es.config=#{prefix}/config/elasticsearch.yml
@@ -93,7 +93,7 @@ def startup_plist
93 93
           <key>KeepAlive</key>
94 94
           <true/>
95 95
           <key>Label</key>
96  
-          <string>org.elasticsearch</string>
  96
+          <string>#{plist_name}</string>
97 97
           <key>ProgramArguments</key>
98 98
           <array>
99 99
             <string>#{HOMEBREW_PREFIX}/bin/elasticsearch</string>
28  Library/Formula/isc-dhcp.rb
@@ -71,30 +71,30 @@ def install
71 71
     end
72 72
 
73 73
     # sample launchd plists
74  
-    (prefix+'org.isc.dhcpd.plist').write dhcpd_plist
75  
-    (prefix+'org.isc.dhcpd.plist').chmod 0644
76  
-    (prefix+'org.isc.dhcpd6.plist').write dhcpd6_plist
77  
-    (prefix+'org.isc.dhcpd6.plist').chmod 0644
  74
+    plist_path.write dhcpd_plist
  75
+    plist_path.chmod 0644
  76
+    (prefix+'homebrew.mxcl.dhcpd6.plist').write dhcpd6_plist
  77
+    (prefix+'homebrew.mxcl.dhcpd6.plist').chmod 0644
78 78
   end
79 79
 
80 80
   def caveats
81 81
     <<-EOCAVEATS.undent
82  
-    This install of dhcpd expects config files to be in /usr/local/etc.
83  
-    All state files (leases and pids) are stored in /usr/local/var/dhcpd.
  82
+    This install of dhcpd expects config files to be in #{etc}.
  83
+    All state files (leases and pids) are stored in #{var}/dhcpd.
84 84
 
85 85
     Dhcpd needs to run as root since it listens on privileged ports.
86 86
     Sample launchd plists to achieve this have been provided at:
87  
-      #{prefix}/org.isc.dhcpd.plist
  87
+      #{plist_path}
88 88
     and:
89  
-      #{prefix}/org.isc.dhcpd6.plist
  89
+      #{prefix}/homebrew.mxcl.dhcpd6.plist
90 90
 
91 91
     There are two plists because a single dhcpd process may do either
92 92
     DHCPv4 or DHCPv6 but not both. Use one or both as needed.
93 93
 
94 94
     Copy the plists to /Library/LaunchDaemons and start the services with
95 95
       cd /Library/LaunchDaemons
96  
-      launchctl load -w org.isc.dhcpd.plist
97  
-      launchctl load -w org.isc.dhcpd6.plist
  96
+      launchctl load -w #{plist_path.basename}
  97
+      launchctl load -w homebrew.mxcl.dhcpd6.plist
98 98
 
99 99
     Note that you must create the appropriate config files before starting
100 100
     the services or dhcpd will refuse to run.
@@ -103,8 +103,8 @@ def caveats
103 103
 
104 104
     Sample config files may be found in #{etc}.
105 105
     If you change the config, restart dhcpd with one or both of
106  
-      launchctl stop org.isc.dhcpd
107  
-      launchctl stop org.isc.dhcpd6
  106
+      launchctl stop #{plist_name}
  107
+      launchctl stop homebrew.mxcl.dhcpd6
108 108
     EOCAVEATS
109 109
   end
110 110
 
@@ -115,7 +115,7 @@ def dhcpd_plist
115 115
                     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
116 116
     <plist version='1.0'>
117 117
     <dict>
118  
-    <key>Label</key><string>org.isc.dhcpd</string>
  118
+    <key>Label</key><string>#{plist_name}</string>
119 119
     <key>ProgramArguments</key>
120 120
       <array>
121 121
         <string>#{HOMEBREW_PREFIX}/sbin/dhcpd</string>
@@ -137,7 +137,7 @@ def dhcpd6_plist
137 137
                     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
138 138
     <plist version='1.0'>
139 139
     <dict>
140  
-    <key>Label</key><string>org.isc.dhcpd</string>
  140
+    <key>Label</key><string>#{plist_name}</string>
141 141
     <key>ProgramArguments</key>
142 142
       <array>
143 143
         <string>#{HOMEBREW_PREFIX}/sbin/dhcpd</string>
18  Library/Formula/jenkins.rb
@@ -10,20 +10,20 @@ class Jenkins < Formula
10 10
   def install
11 11
     system "mvn clean install -pl war -am -DskipTests && mv war/target/jenkins.war ." if ARGV.build_head?
12 12
     lib.install "jenkins.war"
13  
-    (prefix+'org.jenkins-ci.plist').write startup_plist
14  
-    (prefix+'org.jenkins-ci.plist').chmod 0644
  13
+    plist_path.write startup_plist
  14
+    plist_path.chmod 0644
15 15
   end
16 16
 
17 17
   def caveats; <<-EOS
18 18
 If this is your first install, automatically load on login with:
19 19
     mkdir -p ~/Library/LaunchAgents
20  
-    cp #{prefix}/org.jenkins-ci.plist ~/Library/LaunchAgents/
21  
-    launchctl load -w ~/Library/LaunchAgents/org.jenkins-ci.plist
  20
+    cp #{plist_path} ~/Library/LaunchAgents/
  21
+    launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
22 22
 
23  
-If this is an upgrade and you already have the org.jenkins-ci.plist loaded:
24  
-    launchctl unload -w ~/Library/LaunchAgents/org.jenkins-ci.plist
25  
-    cp #{prefix}/org.jenkins-ci.plist ~/Library/LaunchAgents/
26  
-    launchctl load -w ~/Library/LaunchAgents/org.jenkins-ci.plist
  23
+If this is an upgrade and you already have the #{plist_path} loaded:
  24
+    launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  25
+    cp #{plist_path} ~/Library/LaunchAgents/
  26
+    launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
27 27
 
28 28
 Or start it manually:
29 29
     java -jar #{lib}/jenkins.war
@@ -42,7 +42,7 @@ def startup_plist
42 42
 <plist version="1.0">
43 43
 <dict>
44 44
     <key>Label</key>
45  
-    <string>Jenkins</string>
  45
+    <string>#{plist_name}</string>
46 46
     <key>ProgramArguments</key>
47 47
     <array>
48 48
     <string>/usr/bin/java</string>
20  Library/Formula/mariadb.rb
@@ -65,8 +65,8 @@ def install
65 65
     (prefix+'mysql-test').rmtree unless ARGV.include? '--with-tests' # save 121MB!
66 66
     (prefix+'sql-bench').rmtree unless ARGV.include? '--with-bench'
67 67
 
68  
-    (prefix+'com.mysql.mysqld.plist').write startup_plist
69  
-    (prefix+'com.mysql.mysqld.plist').chmod 0644
  68
+    plist_path.write startup_plist
  69
+    plist_path.chmod 0644
70 70
   end
71 71
 
72 72
   def caveats; <<-EOS.undent
@@ -75,16 +75,16 @@ def caveats; <<-EOS.undent
75 75
         mysql_install_db
76 76
 
77 77
     If this is your first install, automatically load on login with:
78  
-        cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
79  
-        launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
  78
+        cp #{plist_path} ~/Library/LaunchAgents
  79
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
80 80
 
81  
-    If this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
82  
-        launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
83  
-        cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents
84  
-        launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
  81
+    If this is an upgrade and you already have the #{plist_path} loaded:
  82
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  83
+        cp #{plist_path} ~/Library/LaunchAgents
  84
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
85 85
 
86 86
     Note on upgrading:
87  
-        We overwrite any existing com.mysql.mysqld.plist in ~/Library/LaunchAgents
  87
+        We overwrite any existing #{plist_path} in ~/Library/LaunchAgents
88 88
         if we are upgrading because previous versions of this brew created the
89 89
         plist with a version specific program argument.
90 90
 
@@ -101,7 +101,7 @@ def startup_plist; <<-EOPLIST.undent
101 101
       <key>KeepAlive</key>
102 102
       <true/>
103 103
       <key>Label</key>
104  
-      <string>com.mysql.mysqld</string>
  104
+      <string>#{plist_name}</string>
105 105
       <key>Program</key>
106 106
       <string>#{HOMEBREW_PREFIX}/bin/mysqld_safe</string>
107 107
       <key>RunAtLoad</key>
18  Library/Formula/memcached.rb
@@ -22,20 +22,20 @@ def install
22 22
     system "./configure", *args
23 23
     system "make install"
24 24
 
25  
-    (prefix+'com.danga.memcached.plist').write startup_plist
26  
-    (prefix+'com.danga.memcached.plist').chmod 0644
  25
+    plist_path.write startup_plist
  26
+    plist_path.chmod 0644
27 27
   end
28 28
 
29 29
   def caveats; <<-EOS.undent
30 30
     You can enable memcached to automatically load on login with:
31 31
         mkdir -p ~/Library/LaunchAgents
32  
-        cp #{prefix}/com.danga.memcached.plist ~/Library/LaunchAgents/
33  
-        launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist
  32
+        cp #{plist_path} ~/Library/LaunchAgents/
  33
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
34 34
 
35  
-    If this is an upgrade and you already have the com.danga.memcached.plist loaded:
36  
-        launchctl unload -w ~/Library/LaunchAgents/com.danga.memcached.plist
37  
-        cp #{prefix}/com.danga.memcached.plist ~/Library/LaunchAgents/com.danga.memcached.plist
38  
-        launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist
  35
+    If this is an upgrade and you already have the #{plist_path} loaded:
  36
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  37
+        cp #{plist_path} ~/Library/LaunchAgents/#{plist_path.basename}
  38
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
39 39
 
40 40
     Or start it manually:
41 41
         #{HOMEBREW_PREFIX}/bin/memcached
@@ -51,7 +51,7 @@ def startup_plist
51 51
 <plist version="1.0">
52 52
 <dict>
53 53
   <key>Label</key>
54  
-  <string>com.danga.memcached</string>
  54
+  <string>#{plist_name}</string>
55 55
   <key>KeepAlive</key>
56 56
   <true/>
57 57
   <key>ProgramArguments</key>
18  Library/Formula/mongodb.rb
@@ -43,8 +43,8 @@ def install
43 43
 
44 44
     # Write the configuration files and launchd script
45 45
     (prefix+'mongod.conf').write mongodb_conf
46  
-    (prefix+'org.mongodb.mongod.plist').write startup_plist
47  
-    (prefix+'org.mongodb.mongod.plist').chmod 0644
  46
+    plist_path.write startup_plist
  47
+    plist_path.chmod 0644
48 48
   end
49 49
 
50 50
   def caveats
@@ -52,13 +52,13 @@ def caveats
52 52
     s += <<-EOS.undent
53 53
     If this is your first install, automatically load on login with:
54 54
         mkdir -p ~/Library/LaunchAgents
55  
-        cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents/
56  
-        launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  55
+        cp #{plist_path} ~/Library/LaunchAgents/
  56
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
57 57
 
58  
-    If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
59  
-        launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
60  
-        cp #{prefix}/org.mongodb.mongod.plist ~/Library/LaunchAgents/
61  
-        launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  58
+    If this is an upgrade and you already have the #{plist_path} loaded:
  59
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  60
+        cp #{plist_path} ~/Library/LaunchAgents/
  61
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
62 62
 
63 63
     Or start it manually:
64 64
         mongod run --config #{prefix}/mongod.conf
@@ -118,7 +118,7 @@ def startup_plist
118 118
 <plist version="1.0">
119 119
 <dict>
120 120
   <key>Label</key>
121  
-  <string>org.mongodb.mongod</string>
  121
+  <string>#{plist_path}</string>
122 122
   <key>ProgramArguments</key>
123 123
   <array>
124 124
     <string>#{HOMEBREW_PREFIX}/bin/mongod</string>
18  Library/Formula/mysql.rb
@@ -75,8 +75,8 @@ def install
75 75
     system "make"
76 76
     system "make install"
77 77
 
78  
-    (prefix+'com.mysql.mysqld.plist').write startup_plist
79  
-    (prefix+'com.mysql.mysqld.plist').chmod 0644
  78
+    plist_path.write startup_plist
  79
+    plist_path.chmod 0644
80 80
 
81 81
     # Don't create databases inside of the prefix!
82 82
     # See: https://github.com/mxcl/homebrew/issues/4975
@@ -121,13 +121,13 @@ def caveats; <<-EOS.undent
121 121
     To launch on startup:
122 122
     * if this is your first install:
123 123
         mkdir -p ~/Library/LaunchAgents
124  
-        cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents/
125  
-        launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
  124
+        cp #{plist_path} ~/Library/LaunchAgents/
  125
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
126 126
 
127  
-    * if this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
128  
-        launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
129  
-        cp #{prefix}/com.mysql.mysqld.plist ~/Library/LaunchAgents/
130  
-        launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
  127
+    * if this is an upgrade and you already have the #{plist_path} loaded:
  128
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  129
+        cp #{plist_path} ~/Library/LaunchAgents/
  130
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
131 131
 
132 132
     You may also need to edit the plist to use the correct "UserName".
133 133
 
@@ -142,7 +142,7 @@ def startup_plist; <<-EOPLIST.undent
142 142
       <key>KeepAlive</key>
143 143
       <true/>
144 144
       <key>Label</key>
145  
-      <string>com.mysql.mysqld</string>
  145
+      <string>#{plist_name}</string>
146 146
       <key>Program</key>
147 147
       <string>#{HOMEBREW_PREFIX}/bin/mysqld_safe</string>
148 148
       <key>RunAtLoad</key>
8  Library/Formula/nagios.rb
@@ -37,7 +37,7 @@ def install
37 37
     # Install config
38 38
     system "make install-config"
39 39
     system "make install-webconf"
40  
-    (share+'org.nagios.plist').write startup_plist
  40
+    (share+plist_path).write startup_plist
41 41
 
42 42
     # Symlink plugins
43 43
     libexec.rmdir
@@ -53,7 +53,7 @@ def startup_plist
53 53
             <key>KeepAlive</key>
54 54
             <true/>
55 55
             <key>Label</key>
56  
-            <string>org.nagios</string>
  56
+            <string>#{plist_name}</string>
57 57
             <key>ProgramArguments</key>
58 58
             <array>
59 59
                     <string>#{HOMEBREW_PREFIX}/bin/nagios</string>
@@ -97,8 +97,8 @@ def caveats
97 97
 
98 98
     If you want to run nagios automatically at startup:
99 99
 
100  
-      sudo cp #{share}/org.nagios.plist /Library/LaunchDaemons/
101  
-      sudo launchctl load -w /Library/LaunchDaemons/org.nagios.plist
  100
+      sudo cp #{share}/#{plist_path.basename} /Library/LaunchDaemons/
  101
+      sudo launchctl load -w /Library/LaunchDaemons/#{plist_path.basename}
102 102
 
103 103
     ...or simply run it on demand:
104 104
 
10  Library/Formula/nginx.rb
@@ -56,8 +56,8 @@ def install
56 56
     system "make install"
57 57
     man8.install "objs/nginx.8"
58 58
 
59  
-    (prefix+'org.nginx.nginx.plist').write startup_plist
60  
-    (prefix+'org.nginx.nginx.plist').chmod 0644
  59
+    plist_path.write startup_plist
  60
+    plist_path.chmod 0644
61 61
   end
62 62
 
63 63
   def caveats; <<-EOS.undent
@@ -70,8 +70,8 @@ def caveats; <<-EOS.undent
70 70
 
71 71
     You can start nginx automatically on login running as your user with:
72 72
       mkdir -p ~/Library/LaunchAgents
73  
-      cp #{prefix}/org.nginx.nginx.plist ~/Library/LaunchAgents/
74  
-      launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist
  73
+      cp #{plist_path} ~/Library/LaunchAgents/
  74
+      launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
75 75
 
76 76
     Though note that if running as your user, the launch agent will fail if you
77 77
     try to use a port below 1024 (such as http's default of 80.)
@@ -85,7 +85,7 @@ def startup_plist
85 85
 <plist version="1.0">
86 86
   <dict>
87 87
     <key>Label</key>
88  
-    <string>org.nginx.nginx</string>
  88
+    <string>#{plist_name}</string>
89 89
     <key>RunAtLoad</key>
90 90
     <true/>
91 91
     <key>KeepAlive</key>
18  Library/Formula/offline-imap.rb
@@ -12,8 +12,8 @@ def install
12 12
     prefix.install [ 'offlineimap.conf', 'offlineimap.conf.minimal' ]
13 13
     bin.mkpath
14 14
     ln_s libexec+'offlineimap.py', bin+'offlineimap'
15  
-    (prefix+'org.offlineimap.plist').write startup_plist
16  
-    (prefix+'org.offlineimap.plist').chmod 0644
  15
+    plist_path.write startup_plist
  16
+    plist_path.chmod 0644
17 17
   end
18 18
 
19 19
   def caveats; <<-EOS.undent
@@ -28,13 +28,13 @@ def caveats; <<-EOS.undent
28 28
     To launch on startup and run every 5 minutes:
29 29
     * if this is your first install:
30 30
         mkdir -p ~/Library/LaunchAgents
31  
-        cp #{prefix}/org.offlineimap.plist ~/Library/LaunchAgents/
32  
-        launchctl load -w ~/Library/LaunchAgents/org.offlineimap.plist
  31
+        cp #{plist_path} ~/Library/LaunchAgents/
  32
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
33 33
 
34  
-    * if this is an upgrade and you already have the org.offlineimap.plist loaded:
35  
-        launchctl unload -w ~/Library/LaunchAgents/org.offlineimap.plist
36  
-        cp #{prefix}/org.offlineimap.plist ~/Library/LaunchAgents/
37  
-        launchctl load -w ~/Library/LaunchAgents/org.offlineimap.plist
  34
+    * if this is an upgrade and you already have the #{plist_path} loaded:
  35
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  36
+        cp #{plist_path} ~/Library/LaunchAgents/
  37
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
38 38
 
39 39
     EOS
40 40
   end
@@ -47,7 +47,7 @@ def startup_plist; <<-EOPLIST.undent
47 47
         <key>KeepAlive</key>
48 48
         <false/>
49 49
         <key>Label</key>
50  
-        <string>org.offlineimap</string>
  50
+        <string>#{plist_name}</string>
51 51
         <key>ProgramArguments</key>
52 52
         <array>
53 53
           <string>#{HOMEBREW_PREFIX}/bin/offlineimap</string>
12  Library/Formula/openvpn.rb
@@ -36,8 +36,8 @@ def install
36 36
     (var + 'run/openvpn').mkpath
37 37
 
38 38
     # Write the launchd script
39  
-    (prefix + 'org.openvpn.plist').write startup_plist
40  
-    (prefix + 'org.openvpn.plist').chmod 0644
  39
+    plist_path.write startup_plist
  40
+    plist_path.chmod 0644
41 41
   end
42 42
 
43 43
   def caveats; <<-EOS
@@ -58,12 +58,12 @@ def caveats; <<-EOS
58 58
 
59 59
 2) Install the launchd item in /Library/LaunchDaemons, like so:
60 60
 
61  
-   sudo cp -vf #{prefix}/org.openvpn.plist /Library/LaunchDaemons/.
62  
-   sudo chown -v root:wheel /Library/LaunchDaemons/org.openvpn.plist
  61
+   sudo cp -vf #{plist_path} /Library/LaunchDaemons/.
  62
+   sudo chown -v root:wheel /Library/LaunchDaemons/#{plist_path.basename}
63 63
 
64 64
 3) Start the daemon using:
65 65
 
66  
-   sudo launchctl load /Library/LaunchDaemons/org.openvpn.plist
  66
+   sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
67 67
 
68 68
 Next boot of system will automatically start OpenVPN.
69 69
 EOS
@@ -76,7 +76,7 @@ def startup_plist
76 76
 <plist version="1.0">
77 77
 <dict>
78 78
   <key>Label</key>
79  
-  <string>org.openvpn</string>
  79
+  <string>#{plist_name}</string>
80 80
   <key>ProgramArguments</key>
81 81
   <array>
82 82
     <string>#{HOMEBREW_PREFIX}/sbin/openvpn</string>
16  Library/Formula/percona-server.rb
@@ -73,7 +73,7 @@ def install
73 73
     system "make"
74 74
     system "make install"
75 75
 
76  
-    (prefix+'com.percona.mysqld.plist').write startup_plist
  76
+    plist_path.write startup_plist
77 77
 
78 78
     # Don't create databases inside of the prefix!
79 79
     # See: https://github.com/mxcl/homebrew/issues/4975
@@ -118,13 +118,13 @@ def caveats; <<-EOS.undent
118 118
     To launch on startup:
119 119
     * if this is your first install:
120 120
         mkdir -p ~/Library/LaunchAgents
121  
-        cp #{prefix}/com.percona.mysqld.plist ~/Library/LaunchAgents/
122  
-        launchctl load -w ~/Library/LaunchAgents/com.percona.mysqld.plist
  121
+        cp #{plist_path} ~/Library/LaunchAgents/
  122
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
123 123
 
124  
-    * if this is an upgrade and you already have the com.percona.mysqld.plist loaded:
125  
-        launchctl unload -w ~/Library/LaunchAgents/com.percona.mysqld.plist
126  
-        cp #{prefix}/com.percona.mysqld.plist ~/Library/LaunchAgents/
127  
-        launchctl load -w ~/Library/LaunchAgents/com.percona.mysqld.plist
  124
+    * if this is an upgrade and you already have the #{plist_path} loaded:
  125
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  126
+        cp #{plist_path} ~/Library/LaunchAgents/
  127
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
128 128
 
129 129
     You may also need to edit the plist to use the correct "UserName".
130 130
 
@@ -139,7 +139,7 @@ def startup_plist; <<-EOPLIST.undent
139 139
       <key>KeepAlive</key>
140 140
       <true/>
141 141
       <key>Label</key>
142  
-      <string>com.percona.mysqld</string>
  142
+      <string>#{plist_name}</string>
143 143
       <key>Program</key>
144 144
       <string>#{HOMEBREW_PREFIX}/bin/mysqld_safe</string>
145 145
       <key>RunAtLoad</key>
18  Library/Formula/pgbouncer.rb
@@ -16,8 +16,8 @@ def install
16 16
     bin.install "etc/mkauth.py"
17 17
     etc.install %w(etc/pgbouncer.ini etc/userlist.txt)
18 18
 
19  
-    (prefix+'org.postgresql.pgbouncer.plist').write startup_plist
20  
-    (prefix+'org.postgresql.pgbouncer.plist').chmod 0644
  19
+    plist_path.write startup_plist
  20
+    plist_path.chmod 0644
21 21
   end
22 22
 
23 23
   def caveats
@@ -31,14 +31,14 @@ def caveats
31 31
 
32 32
 If this is your first install, automatically load on login with:
33 33
     mkdir -p ~/Library/LaunchAgents
34  
-    cp #{prefix}/org.postgresql.pgbouncer.plist ~/Library/LaunchAgents/
35  
-    launchctl load -w ~/Library/LaunchAgents/org.postgresql.pgbouncer.plist
  34
+    cp #{plist_path} ~/Library/LaunchAgents/
  35
+    launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
36 36
 
37  
-If this is an upgrade and you already have the org.postgresql.pgbouncer.plist
  37
+If this is an upgrade and you already have the #{plist_path}
38 38
 loaded:
39  
-    launchctl unload -w ~/Library/LaunchAgents/org.postgresql.pgbouncer.plist
40  
-    cp #{prefix}/org.postgresql.pgbouncer.plist ~/Library/LaunchAgents/
41  
-    launchctl load -w ~/Library/LaunchAgents/org.postgresql.pgbouncer.plist
  39
+    launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  40
+    cp #{plist_path} ~/Library/LaunchAgents/
  41
+    launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
42 42
 
43 43
 Or start manually with:
44 44
     pgbouncer -q #{etc}/pgbouncer.ini
@@ -54,7 +54,7 @@ def startup_plist
54 54
   <key>KeepAlive</key>
55 55
   <true/>
56 56
   <key>Label</key>
57  
-  <string>org.postgresql.pgbouncer</string>
  57
+  <string>#{plist_name}</string>
58 58
   <key>ProgramArguments</key>
59 59
   <array>
60 60
     <string>#{HOMEBREW_PREFIX}/bin/pgbouncer</string>
8  Library/Formula/pincaster.rb
@@ -16,14 +16,14 @@ def install
16 16
 
17 17
     etc.install "pincaster.conf"
18 18
     (var+"db/pincaster/").mkpath
19  
-    (prefix+'com.github.pincaster.plist').write startup_plist
20  
-    (prefix+'com.github.pincaster.plist').chmod 0644
  19
+    plist_path.write startup_plist
  20
+    plist_path.chmod 0644
21 21
   end
22 22
 
23 23
   def caveats
24 24
     <<-EOS.undent
25 25
       Automatically load on login with:
26  
-        launchctl load -w #{prefix}/com.github.pincaster.plist
  26
+        launchctl load -w #{plist_path}
27 27
 
28 28
       To start pincaster manually:
29 29
         pincaster #{etc}/pincaster.conf
@@ -39,7 +39,7 @@ def startup_plist
39 39
     <key>KeepAlive</key>
40 40
     <true/>
41 41
     <key>Label</key>
42  
-    <string>com.github.pincaster</string>
  42
+    <string>#{plist_name}</string>
43 43
     <key>ProgramArguments</key>
44 44
     <array>
45 45
       <string>#{HOMEBREW_PREFIX}/bin/pincaster</string>
18  Library/Formula/postgresql.rb
@@ -56,8 +56,8 @@ def install
56 56
     system "./configure", *args
57 57
     system "make install-world"
58 58
 
59  
-    (prefix+'org.postgresql.postgres.plist').write startup_plist
60  
-    (prefix+'org.postgresql.postgres.plist').chmod 0644
  59
+    plist_path.write startup_plist
  60
+    plist_path.chmod 0644
61 61
   end
62 62
 
63 63
   def check_python_arch
@@ -110,13 +110,13 @@ def caveats
110 110
 
111 111
 If this is your first install, automatically load on login with:
112 112
   mkdir -p ~/Library/LaunchAgents
113  
-  cp #{prefix}/org.postgresql.postgres.plist ~/Library/LaunchAgents/
114  
-  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
  113
+  cp #{plist_path} ~/Library/LaunchAgents/
  114
+  launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
115 115
 
116  
-If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
117  
-  launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
118  
-  cp #{prefix}/org.postgresql.postgres.plist ~/Library/LaunchAgents/
119  
-  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
  116
+If this is an upgrade and you already have the #{plist_path} loaded:
  117
+  launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  118
+  cp #{plist_path} ~/Library/LaunchAgents/
  119
+  launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
120 120
 
121 121
 Or start manually with:
122 122
   pg_ctl -D #{var}/postgres -l #{var}/postgres/server.log start
@@ -152,7 +152,7 @@ def startup_plist
152 152
   <key>KeepAlive</key>
153 153
   <true/>
154 154
   <key>Label</key>
155  
-  <string>org.postgresql.postgres</string>
  155
+  <string>#{plist_name}</string>
156 156
   <key>ProgramArguments</key>
157 157
   <array>
158 158
     <string>#{HOMEBREW_PREFIX}/bin/postgres</string>
18  Library/Formula/pure-ftpd.rb
@@ -27,21 +27,21 @@ def install
27 27
 
28 28
     system "./configure", *args
29 29
     system "make install"
30  
-    (prefix+'org.pureftpd.pure-ftpd.plist').write startup_plist
31  
-    (prefix+'org.pureftpd.pure-ftpd.plist').chmod 0644
  30
+    plist_path.write startup_plist
  31
+    plist_path.chmod 0644
32 32
   end
33 33
 
34 34
   def caveats
35 35
     <<-EOS.undent
36 36
     If this is your first install, automatically load on login with:
37 37
         mkdir -p ~/Library/LaunchAgents
38  
-        cp #{prefix}/org.pureftpd.pure-ftpd.plist ~/Library/LaunchAgents/
39  
-        launchctl load -w ~/Library/LaunchAgents/org.pureftpd.pure-ftpd.plist
  38
+        cp #{plist_path} ~/Library/LaunchAgents/
  39
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
40 40
 
41  
-    If this is an upgrade and you already have the org.pureftpd.pure-ftpd.plist loaded:
42  
-        launchctl unload -w ~/Library/LaunchAgents/org.pureftpd.pure-ftpd.plist
43  
-        cp #{prefix}/org.pureftpd.pure-ftpd.plist ~/Library/LaunchAgents/
44  
-        launchctl load -w ~/Library/LaunchAgents/org.pureftpd.pure-ftpd.plist
  41
+    If this is an upgrade and you already have the #{plist_path.basename} loaded:
  42
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  43
+        cp #{plist_path} ~/Library/LaunchAgents/
  44
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
45 45
 
46 46
       To start pure-ftpd manually:
47 47
         pure-ftpd <options>
@@ -57,7 +57,7 @@ def startup_plist
57 57
     <key>KeepAlive</key>
58 58
     <true/>
59 59
     <key>Label</key>
60  
-    <string>org.pureftpd.pure-ftpd</string>
  60
+    <string>#{plist_name}</string>
61 61
     <key>ProgramArguments</key>
62 62
     <array>
63 63
       <string>#{HOMEBREW_PREFIX}/sbin/pure-ftpd</string>
18  Library/Formula/rabbitmq.rb
@@ -35,21 +35,21 @@ def install
35 35
     # therefore need to add this path for erl -pa
36 36
     inreplace sbin+'rabbitmq-env', '${SCRIPT_DIR}/..', target_dir
37 37
 
38  
-    (prefix+'com.rabbitmq.rabbitmq-server.plist').write startup_plist
39  
-    (prefix+'com.rabbitmq.rabbitmq-server.plist').chmod 0644
  38
+    plist_path.write startup_plist
  39
+    plist_path.chmod 0644
40 40
   end
41 41
 
42 42
   def caveats
43 43
     <<-EOS.undent
44 44
     If this is your first install, automatically load on login with:
45 45
         mkdir -p ~/Library/LaunchAgents
46  
-        cp #{prefix}/com.rabbitmq.rabbitmq-server.plist ~/Library/LaunchAgents/
47  
-        launchctl load -w ~/Library/LaunchAgents/com.rabbitmq.rabbitmq-server.plist
  46
+        cp #{plist_path} ~/Library/LaunchAgents/
  47
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
48 48
 
49  
-    If this is an upgrade and you already have the com.rabbitmq.rabbitmq-server.plist loaded:
50  
-        launchctl unload -w ~/Library/LaunchAgents/com.rabbitmq.rabbitmq-server.plist
51  
-        cp #{prefix}/com.rabbitmq.rabbitmq-server.plist ~/Library/LaunchAgents/
52  
-        launchctl load -w ~/Library/LaunchAgents/com.rabbitmq.rabbitmq-server.plist
  49
+    If this is an upgrade and you already have the #{plist_path} loaded:
  50
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  51
+        cp #{plist_path} ~/Library/LaunchAgents/
  52
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
53 53
 
54 54
       To start rabbitmq-server manually:
55 55
         rabbitmq-server
@@ -64,7 +64,7 @@ def startup_plist
64 64
 <plist version="1.0">
65 65
   <dict>
66 66
     <key>Label</key>
67  
-    <string>com.rabbitmq.rabbitmq-server</string>
  67
+    <string>#{plist_name}</string>
68 68
     <key>Program</key>
69 69
     <string>#{HOMEBREW_PREFIX}/sbin/rabbitmq-server</string>
70 70
     <key>RunAtLoad</key>
18  Library/Formula/redis.rb
@@ -30,21 +30,21 @@ def install
30 30
 
31 31
     doc.install Dir["doc/*"]
32 32
     etc.install "redis.conf"
33  
-    (prefix+'io.redis.redis-server.plist').write startup_plist
34  
-    (prefix+'io.redis.redis-server.plist').chmod 0644
  33
+    plist_path.write startup_plist
  34
+    plist_path.chmod 0644
35 35
   end
36 36
 
37 37
   def caveats
38 38
     <<-EOS.undent
39 39
     If this is your first install, automatically load on login with:
40 40
         mkdir -p ~/Library/LaunchAgents
41  
-        cp #{prefix}/io.redis.redis-server.plist ~/Library/LaunchAgents/
42  
-        launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
  41
+        cp #{plist_path} ~/Library/LaunchAgents/
  42
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
43 43
 
44  
-    If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
45  
-        launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
46  
-        cp #{prefix}/io.redis.redis-server.plist ~/Library/LaunchAgents/
47  
-        launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
  44
+    If this is an upgrade and you already have the #{plist_path} loaded:
  45
+        launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  46
+        cp #{plist_path} ~/Library/LaunchAgents/
  47
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
48 48
 
49 49
       To start redis manually:
50 50
         redis-server #{etc}/redis.conf
@@ -63,7 +63,7 @@ def startup_plist
63 63
     <key>KeepAlive</key>
64 64
     <true/>
65 65
     <key>Label</key>
66  
-    <string>io.redis.redis-server</string>
  66
+    <string>#{plist_name}</string>
67 67
     <key>ProgramArguments</key>
68 68
     <array>
69 69
       <string>#{HOMEBREW_PREFIX}/bin/redis-server</string>
14  Library/Formula/sickbeard.rb
@@ -13,8 +13,8 @@ def install
13 13
     prefix.install Dir['*']
14 14
     bin.mkpath
15 15
     (bin+"sickbeard").write(startup_script)
16  
-    (prefix+"com.sickbeard.sickbeard.plist").write(startup_plist)
17  
-    (prefix+"com.sickbeard.sickbeard.plist").chmod 0644
  16
+    plist_path.write(startup_plist)
  17
+    plist_path.chmod 0644
18 18
   end
19 19
 
20 20
   def startup_plist; <<-EOS.undent
@@ -23,7 +23,7 @@ def startup_plist; <<-EOS.undent
23 23
     <plist version="1.0">
24 24
     <dict>
25 25
       <key>Label</key>
26  
-      <string>com.sickbeard.sickbeard</string>
  26
+      <string>#{plist_name}</string>
27 27
       <key>ProgramArguments</key>
28 28
       <array>
29 29
            <string>#{HOMEBREW_PREFIX}/bin/sickbeard</string>
@@ -70,12 +70,12 @@ def caveats; <<-EOS.undent
70 70
     To launch automatically on startup, copy and paste the following into a terminal:
71 71
 
72 72
         mkdir -p ~/Library/LaunchAgents
73  
-        (launchctl unload -w ~/Library/LaunchAgents/com.sickbeard.sickbeard.plist 2>/dev/null || true)
74  
-        ln -sf #{prefix}/com.sickbeard.sickbeard.plist ~/Library/LaunchAgents/com.sickbeard.sickbeard.plist
75  
-        launchctl load -w ~/Library/LaunchAgents/com.sickbeard.sickbeard.plist
  73
+        (launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename} 2>/dev/null || true)
  74
+        ln -sf #{plist_path} ~/Library/LaunchAgents/#{plist_path.basename}
  75
+        launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
76 76
 
77 77
     You may want to edit:
78  
-      #{prefix}/com.sickbeard.sickbeard.plist
  78
+      #{plist_path}
79 79
     to change the port (default: 8081) or user (default: #{`whoami`.chomp}).
80 80
     EOS
81 81
   end
12  Library/Formula/sshguard.rb
@@ -18,19 +18,19 @@ def install
18 18
                           "--with-firewall=ipfw"
19 19
     system "make install"
20 20
 
21  
-    (prefix+'net.sshguard.plist').write startup_plist
22  
-    (prefix+'net.sshguard.plist').chmod 0644
  21
+    plist_path.write startup_plist
  22
+    plist_path.chmod 0644
23 23
   end
24 24
 
25 25
   def caveats; <<-EOS
26 26
 1) Install the launchd item in /Library/LaunchDaemons, like so:
27 27
 
28  
-   sudo cp -vf #{prefix}/net.sshguard.plist /Library/LaunchDaemons/
29  
-   sudo chown -v root:wheel /Library/LaunchDaemons/net.sshguard.plist
  28
+   sudo cp -vf #{plist_path} /Library/LaunchDaemons/
  29
+   sudo chown -v root:wheel /Library/LaunchDaemons/#{plist_path.basename}
30 30
 
31 31
 2) Start the daemon using:
32 32
 
33  
-   sudo launchctl load /Library/LaunchDaemons/net.sshguard.plist
  33
+   sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
34 34
 
35 35
    Next boot of system will automatically start sshguard.
36 36
 EOS
@@ -43,7 +43,7 @@ def startup_plist
43 43
 <plist version="1.0">
44 44
 <dict>
45 45
   <key>Label</key>
46  
-  <string>net.sshguard</string>
  46
+  <string>#{plist_name}</string>
47 47
   <key>KeepAlive</key>
48 48
   <true/>
49 49
   <key>ProgramArguments</key>
10  Library/Formula/tor.rb
@@ -12,8 +12,8 @@ def install
12 12
                           "--prefix=#{prefix}"
13 13
     system "make install"
14 14
 
15  
-    (prefix+'org.tor.plist').write startup_plist
16  
-    (prefix+'org.tor.plist').chmod 0644
  15
+    plist_path.write startup_plist
  16
+    plist_path.chmod 0644
17 17
   end
18 18
 
19 19
   def startup_plist
@@ -23,7 +23,7 @@ def startup_plist
23 23
 <plist version="1.0">
24 24
   <dict>
25 25
     <key>Label</key>
26  
-    <string>org.tor</string>
  26
+    <string>#{plist_name}</string>
27 27
     <key>RunAtLoad</key>
28 28
     <true/>
29 29
     <key>KeepAlive</key>
@@ -44,8 +44,8 @@ def startup_plist
44 44
   def caveats; <<-EOS.undent
45 45
     You can start tor automatically on login with:
46 46
       mkdir -p ~/Library/LaunchAgents
47  
-      cp #{prefix}/org.tor.plist ~/Library/LaunchAgents/
48  
-      launchctl load -w ~/Library/LaunchAgents/org.tor.plist
  47
+      cp #{plist_path} ~/Library/LaunchAgents/
  48
+      launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
49 49
     EOS
50 50
   end
51 51
 end
4  Library/Homebrew/formula.rb
@@ -208,6 +208,10 @@ def etc; HOMEBREW_PREFIX+'etc' end
208 208
   # generally we don't want var stuff inside the keg
209 209
   def var; HOMEBREW_PREFIX+'var' end
210 210
 
  211
+  # plist name, i.e. the name of the launchd service
  212
+  def plist_name; 'homebrew.mxcl.'+name end
  213
+  def plist_path; prefix+(plist_name+'.plist') end
  214
+
211 215
   # Use the @spec_to_use to detect the download strategy.
212 216
   # Can be overriden to force a custom download strategy
213 217
   def download_strategy

0 notes on commit b5a5217

Please sign in to comment.
Something went wrong with that request. Please try again.