This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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...
1 parent 36929f1 commit 9d587a39a117570c7ec9649619bcbe733f1d910a @karmi karmi committed with klausmeyer Dec 30, 2012
Showing with 17 additions and 34 deletions.
  1. +17 −34 Library/Formula/elasticsearch.rb
@@ -12,64 +12,47 @@ def cluster_name
def install
# Remove Windows files
rm_f Dir["bin/*.bat"]
- # Move JARs from lib to libexec according to homebrew conventions
+
+ # Move libraries to `libexec` directory
libexec.install Dir['lib/*.jar']
- (libexec+'sigar').install Dir['lib/sigar/*.jar']
+ (libexec/'sigar').install Dir['lib/sigar/*.{jar,dylib}']
- # Install everything directly into folder
+ # Install everything else into package directory
prefix.install Dir['*']
# Set up ElasticSearch for local development:
inreplace "#{prefix}/config/elasticsearch.yml" do |s|
-
# 1. Give the cluster a unique name
s.gsub! /#\s*cluster\.name\: elasticsearch/, "cluster.name: #{cluster_name}"
# 2. Configure paths
- s.gsub! /#\s*path\.data\: [^\n]+/, "path.data: #{var}/elasticsearch/"
- s.gsub! /#\s*path\.logs\: [^\n]+/, "path.logs: #{var}/log/elasticsearch/"
+ s.sub! "# path.data: /path/to/data", "path.data: #{var}/elasticsearch/"
+ s.sub! "# path.logs: /path/to/logs", "path.logs: #{var}/log/elasticsearch/"
+ s.sub! "# path.plugins: /path/to/plugins", "path.plugins: #{var}/lib/elasticsearch/plugins"
# 3. Bind to loopback IP for laptops roaming different networks
s.gsub! /#\s*network\.host\: [^\n]+/, "network.host: 127.0.0.1"
-
- # 4. Persist plugins on upgrade
- s.gsub! "# path.plugins: /path/to/plugins", "path.plugins: #{var}/lib/elasticsearch/plugins"
-
end
inreplace "#{bin}/elasticsearch.in.sh" do |s|
- # Replace CLASSPATH paths to use libexec instead of lib
+ # Configure ES_HOME
+ s.sub! /#\!\/bin\/sh\n/, "#!/bin/sh\n\nES_HOME=#{prefix}"
+ # Configure ES_CLASSPATH paths to use libexec instead of lib
s.gsub! /ES_HOME\/lib\//, "ES_HOME/libexec/"
end
- inreplace "#{bin}/elasticsearch" do |s|
- # Set ES_HOME to prefix value
- s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
- end
-
inreplace "#{bin}/plugin" do |s|
- # Set ES_HOME to prefix value
- s.gsub! /^ES_HOME=.*$/, "ES_HOME=#{prefix}"
- # Replace CLASSPATH paths to use libexec instead of lib
- s.gsub! /-cp \".*\"/, '-cp "$ES_HOME/libexec/*"'
+ # Add the proper ES_CLASSPATH configuration
+ s.sub! /SCRIPT="\$0"/, %Q|SCRIPT="$0"\nES_CLASSPATH=#{prefix}/libexec|
+ # Replace paths to use libexec instead of lib
+ s.gsub! /\$ES_HOME\/lib\//, "$ES_CLASSPATH/"
end
end
def caveats; <<-EOS.undent
- If upgrading from 0.18 ElasticSearch requires flushing before shutting
- down the cluster with no indexing operations happening after flush:
- curl host:9200/_flush
-
- See the 'elasticsearch.yml' file for configuration options.
-
- You'll find the ElasticSearch log here:
- open #{var}/log/elasticsearch/#{cluster_name}.log
-
- The folder with cluster data is here:
- open #{var}/elasticsearch/#{cluster_name}/
-
- You should see ElasticSearch running:
- open http://localhost:9200/
+ Data: #{var}/elasticsearch/#{cluster_name}/
+ Logs: #{var}/log/elasticsearch/#{cluster_name}.log
+ Plugins: #{var}/lib/elasticsearch/plugins/
EOS
end

0 comments on commit 9d587a3

Please sign in to comment.