Graylog2 / fpm-recipes

Graylog package build recipes
http://docs.graylog.org/en/latest/pages/installation/operating_system_packages.html
18 stars 18 forks source link

Add package for graylog-enterprise. #98

Closed malcyon closed 3 years ago

malcyon commented 3 years ago

This adds a recipe to build a package of graylog-server with the enterprise plugins bundled in.

malcyon commented 3 years ago

@bernd I don't want to duplicate all these files between the graylog-server directory and the graylog-enterprise directory. What would you think if I replaced most of the files in the graylog-enterprise directory with symlinks? That way, they could be updated in one place.

bernd commented 3 years ago

@bernd I don't want to duplicate all these files between the graylog-server directory and the graylog-enterprise directory. What would you think if I replaced most of the files in the graylog-enterprise directory with symlinks? That way, they could be updated in one place.

@juju2112 Good point! We can do the following to reuse the files from the server. That way we don't have to deal with symlinks.

diff --git recipe.rb recipe.rb
index a97f1c7..70def51 100644
--- recipe.rb
+++ recipe.rb
@@ -37,13 +37,14 @@ class GraylogEnterpriseServer < FPM::Cookery::Recipe
     config_files '/etc/sysconfig/graylog-server'
   end

-  pre_install    'files/pre-install'
-  post_install   'files/post-install'
-  pre_uninstall  'files/pre-uninstall'
-  post_uninstall 'files/post-uninstall'
+  # Use scripts from server recipe to avoid duplicating them
+  pre_install    '../graylog-server/files/pre-install'
+  post_install   '../graylog-server/files/post-install'
+  pre_uninstall  '../graylog-server/files/pre-uninstall'
+  post_uninstall '../graylog-server/files/post-uninstall'

   def build
-    patch(workdir('patches/graylog-server.conf.patch'))
+    patch(workdir('../graylog-server/patches/graylog-server.conf.patch'))
   end

   def install
@@ -80,4 +81,16 @@ class GraylogEnterpriseServer < FPM::Cookery::Recipe
     # Remove unused sigar libs.
     sigar_cleanup(share('graylog-server/lib/sigar'))
   end
+
+  # Override inherited method to make use of files in the server recipe to
+  # avoid duplicating the files in this one
+  def file(path)
+    if File.exists?(super(path))
+      # If the requested file exists in this recipe folder, use it
+      super(path)
+    else
+      # Otherwise use the one from the server recipe
+      workdir('../graylog-server/files')/path
+    end
+  end
 end
bernd commented 3 years ago

@juju2112 Forgot to mention it explicitly: with that diff we can completely remove the files/ folder in the new package recipe.