Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msi: keep fluentdopt when previous options is set #609

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fluent-package/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ class BuildTask
cp("msi/assets/#{PACKAGE_NAME}-prompt.bat", fluent_package_staging_dir)
cp("msi/assets/#{PACKAGE_NAME}-post-install.bat", staging_bindir)
cp("msi/assets/#{PACKAGE_NAME}-post-migration.bat", staging_bindir)
cp("msi/assets/#{PACKAGE_NAME}-post-fluentdwinsvc.rb", staging_bindir)
cp("msi/assets/#{SERVICE_NAME}.bat", fluent_package_staging_dir)
cp("msi/assets/fluent-gem.bat", fluent_package_staging_dir)
cp("msi/assets/#{PACKAGE_NAME}-version.rb", staging_bindir)
Expand Down
37 changes: 37 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,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
18 changes: 16 additions & 2 deletions fluent-package/msi/source.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,25 @@
<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]fluentd.bat&quot; --reg-winsvc i --reg-winsvc-delay-start"/>
<CustomAction Id="InstallFluentdWinSvc"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Execute="deferred"
Return="check"
Impersonate="no" />

<Property Id="InstallFluentdWinSvcFluentdopt" Value=" "/>
<CustomAction Id="SetInstallFluentdWinSvcFluentdoptCommand"
Property="InstallFluentdWinSvcFluentdopt"
Value="&quot;[FLUENTPROJECTLOCATION]bin\ruby.exe&quot; &quot;[FLUENTPROJECTLOCATION]bin\fluent-package-post-fluentdwinsvc.rb&quot; &quot;[FLUENTPROJECTLOCATION]&quot;"/>
<CustomAction Id="InstallFluentdWinSvcFluentdopt"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Execute="deferred"
Return="check"
Impersonate="no" />

<Property Id="CreateCompatTdAgentBat" Value=" "/>
<CustomAction Id="SetCreateCompatTdAgentBat"
Property="CreateCompatTdAgentBat"
Expand Down Expand Up @@ -242,9 +253,12 @@
<Custom Action="SetPostMigrationCommand" Before="PostMigration">WIX_UPGRADE_DETECTED</Custom>
<Custom Action="PostMigration" Before="StartServices">WIX_UPGRADE_DETECTED</Custom>

<Custom Action="SetInstallFluentdWinSvcCommand" After="InstallFiles">NOT Installed</Custom>
<Custom Action="SetInstallFluentdWinSvcCommand" After="PostInstall">NOT Installed</Custom>
<Custom Action="InstallFluentdWinSvc" After="SetInstallFluentdWinSvcCommand">NOT Installed</Custom>

<Custom Action="SetInstallFluentdWinSvcFluentdoptCommand" After="InstallFluentdWinSvc">NOT Installed OR WIX_UPGRADE_DETECTED</Custom>
<Custom Action="InstallFluentdWinSvcFluentdopt" After="SetInstallFluentdWinSvcFluentdoptCommand">NOT Installed OR WIX_UPGRADE_DETECTED</Custom>

<Custom Action="SetCreateCompatTdAgentBat" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="CreateCompatTdAgentBat" After="SetCreateCompatTdAgentBat">NOT Installed</Custom>
<Custom Action="SetCreateCompatTdAgentGemBat" Before="InstallFinalize">NOT Installed</Custom>
Expand Down
Loading