-
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.
msi: keep fluentdopt when previous options is set
Before: * always reset fluentdopt After: * If fluentdopt is empty, set default value * If fluentdopt configuration is changed from default one, keep it. Signed-off-by: Kentaro Hayashi <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
2 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
37 changes: 37 additions & 0 deletions
37
fluent-package/msi/assets/fluent-package-post-fluentdwinsvc.rb
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,37 @@ | ||
require 'fileutils' | ||
require "win32/service" | ||
require "win32/registry" | ||
require "optparse" | ||
include Win32 | ||
|
||
install_dir = "#{ARGV[0]}" | ||
|
||
default_fluentdwinsvc = "-c '#{install_dir}etc\\fluent\\fluentd.conf' -o '#{install_dir}fluentd.log'" | ||
registry_key = "SYSTEM\\CurrentControlSet\\Services\\fluentdwinsvc" | ||
|
||
puts("fluentdwinsvc default: #{default_fluentdwinsvc}") | ||
begin | ||
Win32::Registry::HKEY_LOCAL_MACHINE.open(registry_key, Win32::Registry::KEY_ALL_ACCESS) do |reg| | ||
# Check whether RegValue exists or not | ||
puts("fluentdwinsvc registry key was opened: #{registry_key}") | ||
begin | ||
previous_fluentdopt = reg['fluentdopt', Win32::Registry::REG_SZ] | ||
puts("fluentdwinsvc current value: #{previous_fluentdopt}") | ||
if previous_fluentdopt != default_fluentdwinsvc | ||
puts("fluentdwinsvc: fluentdopt configuration was kept because option was changed from default") | ||
else | ||
puts("fluentdwinsvc: fluentdopt configuration was same as default one: #{default_fluentdwinsvc}") | ||
end | ||
rescue Win32::Registry::Error | ||
# As fluentdopt value does not exist, then set default configuration | ||
puts("fluentdwinsvc: reset to default fluentdopt configuration") | ||
reg['fluentdopt', Win32::Registry::REG_SZ] = default_fluentdwinsvc | ||
end | ||
end | ||
rescue Win32::Registry::Error | ||
# No fluentdwinsvc key yet. | ||
puts("fluentdwinsvc: create #{registory_key} and set default fluentdopt configuration") | ||
Win32::Registry::HKEY_LOCAL_MACHINE.create(registory_key, Win32::Registry::KEY_ALL_ACCESS) do |reg| | ||
reg['fluentdopt', Win32::Registry::REG_SZ] = default_fluentdwinsvc | ||
end | ||
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