-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to check supplementary installed plugin
Examples: Preinstalled plugins: (bundled by default) * fluent-plugin-calyptia-monitoring * fluent-plugin-concat ... * fluent-plugin-utmpx * fluent-plugin-webhdfs Currently Installed Plugins: * fluent-plugin-calyptia-monitoring * fluent-plugin-elasticsearch ... * fluent-plugin-utmpx * fluent-plugin-webhdfs Manually Installed Plugins: * fluent-plugin-concat Signed-off-by: Kentaro Hayashi <kenhys@gmail.com>
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
fluent-package/templates/usr/sbin/fluent-gem-supplemental-list.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!<%= install_path %>/bin/ruby | ||
ENV["GEM_HOME"]="<%= gem_install_path %>/" | ||
ENV["GEM_PATH"]="<%= gem_install_path %>/" | ||
|
||
require "bundler" | ||
require "open3" | ||
require "etc" | ||
|
||
def installed_plugins | ||
stdout, stderr, status = Open3.capture3("<%= install_path %>/bin/fluent-gem list | grep fluent-plugin") | ||
gem_list = [] | ||
if status.success? | ||
lines = stdout.split(/\n/) | ||
lines.each do |line| | ||
gem_list << line.split.first | ||
end | ||
end | ||
gem_list | ||
end | ||
|
||
begin | ||
if Process.uid != 0 | ||
puts(<<EOS) | ||
Failed to execute #{__FILE__}. | ||
You must execute this script with administrator privileges. | ||
|
||
Usage: sudo #{__FILE__} | ||
EOS | ||
exit 1 | ||
end | ||
gemfile_path = "<%= install_path %>/share/Gemfile" | ||
lockfile_path = "<%= install_path %>/share/Gemfile.lock" | ||
bundler_def = Bundler::Definition.build(gemfile_path, lockfile_path, nil) | ||
|
||
bundled_plugins = bundler_def.locked_gems.dependencies.keys.select do |gem_name| | ||
gem_name.start_with?("fluent-plugin-") | ||
end | ||
|
||
puts(<<EOS) | ||
Preinstalled plugins: (bundled by default) | ||
|
||
* #{bundled_plugins.sort.join("\n * ")} | ||
|
||
Currently Installed Plugins: | ||
|
||
* #{installed_plugins.sort.join("\n * ")} | ||
|
||
EOS | ||
unless (installed_plugins - bundled_plugins).empty? | ||
puts(<<EOS) | ||
Manually Installed Plugins: | ||
|
||
* #{(installed_plugins - bundled_plugins).sort.join("\n * ")} | ||
|
||
EOS | ||
end | ||
rescue Bundler::Dsl::DSLError | ||
puts("failed to collect supplemental gem list") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters