Skip to content

Commit

Permalink
msi: keep fluentdopt when previous options is set
Browse files Browse the repository at this point in the history
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
kenhys committed Dec 25, 2023
1 parent c75754e commit 66c394a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions fluent-package/msi/assets/fluent-package-post-fluentdwinsvc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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"

Win32::Registry::HKEY_LOCAL_MACHINE.open(registory_key, Win32::Registry::KEY_ALL_ACCESS) do |reg|
begin
# Check whether RegValue exists or not
previous_fluentdopt = reg['fluentdopt', Win32::Registry::REG_SZ]
if previous_fluentdopt != default_fluentdwinsvc
puts("fluentdwinsvc: fluentdopt configuration was kept because install path (#{install_dir}) of fluent-package was not changed")
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
2 changes: 1 addition & 1 deletion fluent-package/msi/source.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<Property Id="InstallFluentdWinSvc" Value=" "/>
<CustomAction Id="SetInstallFluentdWinSvcCommand"
Property="InstallFluentdWinSvc"
Value="&quot;[FLUENTPROJECTLOCATION]fluentd.bat&quot; --reg-winsvc i --reg-winsvc-delay-start --reg-winsvc-fluentdopt &quot;-c '[FLUENTPROJECTLOCATION]etc\fluent\fluentd.conf' -o '[FLUENTPROJECTLOCATION]fluentd.log'&quot;"/>
Value="&quot;[FLUENTPROJECTLOCATION]bin\ruby.exe&quot; &quot;[FLUENTPROJECTLOCATION]bin\fluent-package-post-fluentdwinsvc.rb&quot; &quot;[FLUENTPROJECTLOCATION]&quot;"/>
<CustomAction Id="InstallFluentdWinSvc"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand Down

0 comments on commit 66c394a

Please sign in to comment.