-
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 <hayashi@clear-code.com>
- Loading branch information
Showing
3 changed files
with
49 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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
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'" | ||
registory_key = "SYSTEM\\CurrentControlSet\\Services\\fluentdwinsvc" | ||
|
||
begin | ||
Win32::Registry::HKEY_LOCAL_MACHINE.open(registory_key, Win32::Registry::KEY_ALL_ACCESS) do |reg| | ||
# Check whether RegValue exists or not | ||
begin | ||
previous_fluentdopt = reg['fluentdopt', Win32::Registry::REG_SZ] | ||
if previous_fluentdopt != default_fluentdwinsvc | ||
puts("fluentdwinsvc: fluentdopt configuration was kept because option was changed from default") | ||
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