Skip to content
This repository
Browse code

Cleanup elasticsearch

Cleanup of the Elasticsearch formula:

1/ Fixed incorrectly installed Sigar libraries on Mac OS X

   Move all neccessary files to `libexec/sigar`.

2/ Removed manipulating the bin scripts, use ES_HOME variable

   Instead of hardcoding paths to Homebrew locations in the `bin/elasticsearch`
   and `bin/plugin` scripts, set up the ES_HOME environment variable
   in the `bin/elasticsearch.in.sh` properly.

   Also, simplify the Regex for replacing path to Elasticsearch classes (`--classpath`)
   in the `bin/plugin` script and use the `ES_CLASSPATH` variable.

3/ Simplified elasticsearch.yml configuration

   Reorganize the commands, use `sub` instead of `gsub`.

4/ Cleaned up the caveats/info section

   Remove redundant information.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information...
commit 9d587a39a117570c7ec9649619bcbe733f1d910a 1 parent 36929f1
Karel Minarik authored December 30, 2012 klausmeyer committed January 10, 2013

Showing 1 changed file with 17 additions and 34 deletions. Show diff stats Hide diff stats

  1. 51  Library/Formula/elasticsearch.rb
51  Library/Formula/elasticsearch.rb
@@ -12,64 +12,47 @@ def cluster_name
12 12
   def install
13 13
     # Remove Windows files
14 14
     rm_f Dir["bin/*.bat"]
15  
-    # Move JARs from lib to libexec according to homebrew conventions
  15
+
  16
+    # Move libraries to `libexec` directory
16 17
     libexec.install Dir['lib/*.jar']
17  
-    (libexec+'sigar').install Dir['lib/sigar/*.jar']
  18
+    (libexec/'sigar').install Dir['lib/sigar/*.{jar,dylib}']
18 19
 
19  
-    # Install everything directly into folder
  20
+    # Install everything else into package directory
20 21
     prefix.install Dir['*']
21 22
 
22 23
     # Set up ElasticSearch for local development:
23 24
     inreplace "#{prefix}/config/elasticsearch.yml" do |s|
24  
-
25 25
       # 1. Give the cluster a unique name
26 26
       s.gsub! /#\s*cluster\.name\: elasticsearch/, "cluster.name: #{cluster_name}"
27 27
 
28 28
       # 2. Configure paths
29  
-      s.gsub! /#\s*path\.data\: [^\n]+/, "path.data: #{var}/elasticsearch/"
30  
-      s.gsub! /#\s*path\.logs\: [^\n]+/, "path.logs: #{var}/log/elasticsearch/"
  29
+      s.sub! "# path.data: /path/to/data", "path.data: #{var}/elasticsearch/"
  30
+      s.sub! "# path.logs: /path/to/logs", "path.logs: #{var}/log/elasticsearch/"
  31
+      s.sub! "# path.plugins: /path/to/plugins", "path.plugins: #{var}/lib/elasticsearch/plugins"
31 32
 
32 33
       # 3. Bind to loopback IP for laptops roaming different networks
33 34
       s.gsub! /#\s*network\.host\: [^\n]+/, "network.host: 127.0.0.1"
34  
-
35  
-      # 4. Persist plugins on upgrade
36  
-      s.gsub! "# path.plugins: /path/to/plugins", "path.plugins: #{var}/lib/elasticsearch/plugins"
37  
-
38 35
     end
39 36
 
40 37
     inreplace "#{bin}/elasticsearch.in.sh" do |s|
41  
-      # Replace CLASSPATH paths to use libexec instead of lib
  38
+      # Configure ES_HOME
  39
+      s.sub!  /#\!\/bin\/sh\n/, "#!/bin/sh\n\nES_HOME=#{prefix}"
  40
+      # Configure ES_CLASSPATH paths to use libexec instead of lib
42 41
       s.gsub! /ES_HOME\/lib\//, "ES_HOME/libexec/"
43 42
     end
44 43
 
45  
-    inreplace "#{bin}/elasticsearch" do |s|
46  
-      # Set ES_HOME to prefix value
47  
-      s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
48  
-    end
49  
-
50 44
     inreplace "#{bin}/plugin" do |s|
51  
-      # Set ES_HOME to prefix value
52  
-      s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
53  
-      # Replace CLASSPATH paths to use libexec instead of lib
54  
-      s.gsub! /-cp \".*\"/, '-cp "$ES_HOME/libexec/*"'
  45
+      # Add the proper ES_CLASSPATH configuration
  46
+      s.sub!  /SCRIPT="\$0"/, %Q|SCRIPT="$0"\nES_CLASSPATH=#{prefix}/libexec|
  47
+      # Replace paths to use libexec instead of lib
  48
+      s.gsub! /\$ES_HOME\/lib\//, "$ES_CLASSPATH/"
55 49
     end
56 50
   end
57 51
 
58 52
   def caveats; <<-EOS.undent
59  
-    If upgrading from 0.18 ElasticSearch requires flushing before shutting
60  
-    down the cluster with no indexing operations happening after flush:
61  
-        curl host:9200/_flush
62  
-
63  
-    See the 'elasticsearch.yml' file for configuration options.
64  
-
65  
-    You'll find the ElasticSearch log here:
66  
-        open #{var}/log/elasticsearch/#{cluster_name}.log
67  
-
68  
-    The folder with cluster data is here:
69  
-        open #{var}/elasticsearch/#{cluster_name}/
70  
-
71  
-    You should see ElasticSearch running:
72  
-        open http://localhost:9200/
  53
+    Data:    #{var}/elasticsearch/#{cluster_name}/
  54
+    Logs:    #{var}/log/elasticsearch/#{cluster_name}.log
  55
+    Plugins: #{var}/lib/elasticsearch/plugins/
73 56
     EOS
74 57
   end
75 58
 

0 notes on commit 9d587a3

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