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

Fix system user/group name in logrotate.d/fluentd again #594

Merged
merged 2 commits into from
Nov 16, 2023
Merged
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
56 changes: 33 additions & 23 deletions fluent-package/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -475,25 +475,14 @@ class BuildTask
end
end

desc "Create fluent-package configuration files from template"
task :fluent_package_config do
fluentd_conf = "etc/#{PACKAGE_DIR}/#{SERVICE_NAME}.conf"
fluentd_conf_default = "opt/#{PACKAGE_DIR}/share/#{SERVICE_NAME}.conf"
configs = [fluentd_conf]
configs.concat([
"etc/logrotate.d/#{SERVICE_NAME}",
fluentd_conf_default,
]) unless windows? || macos?
configs.each do |config|
src =
if config == fluentd_conf_default
template_path(fluentd_conf)
else
template_path(config)
end
dest = File.join(STAGING_DIR, config)
render_template(dest, src, template_params)
end
desc "Create debian fluent-package configuration files from template"
task :deb_fluent_package_config do
render_fluent_package_config('deb')
end

desc "Create RPM fluent-package configuration files from template"
task :rpm_fluent_package_config do
render_fluent_package_config('rpm')
end

desc "Create systemd-tmpfiles configuration files from template"
Expand Down Expand Up @@ -596,16 +585,16 @@ class BuildTask
end

desc "Create configuration files for Red Hat like systems with systemd"
task :rpm_config => [:fluent_package_config, :systemd_tmpfiles_config, :bin_scripts, :rpm_systemd]
task :rpm_config => [:rpm_fluent_package_config, :systemd_tmpfiles_config, :bin_scripts, :rpm_systemd]

desc "Create configuration files for Debian like systems"
task :deb_config => [:fluent_package_config, :systemd_tmpfiles_config, :bin_scripts, :deb_systemd, :deb_scripts]
task :deb_config => [:deb_fluent_package_config, :systemd_tmpfiles_config, :bin_scripts, :deb_systemd, :deb_scripts]

desc "Create configuration files for Windows"
task :msi_config => [:fluent_package_config, :wix_config, :win_batch_files]
task :msi_config => [:rpm_fluent_package_config, :wix_config, :win_batch_files]

desc "Create configuration files for macOS"
task :dmg_config => [:fluent_package_config, :pkgbuild_scripts, :pkgbuild_config, :bin_scripts, :launchctl_config]
task :dmg_config => [:rpm_fluent_package_config, :pkgbuild_scripts, :pkgbuild_config, :bin_scripts, :launchctl_config]
daipom marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down Expand Up @@ -1101,6 +1090,27 @@ class BuildTask
remove_files(git_dir, true)
end
end

def render_fluent_package_config(package_type)
# package_type must be 'deb' or 'rpm'
fluentd_conf = "etc/#{PACKAGE_DIR}/#{SERVICE_NAME}.conf"
fluentd_conf_default = "opt/#{PACKAGE_DIR}/share/#{SERVICE_NAME}.conf"
configs = [fluentd_conf]
configs.concat([
"etc/logrotate.d/#{SERVICE_NAME}",
fluentd_conf_default,
]) unless windows? || macos?
configs.each do |config|
src =
if config == fluentd_conf_default
template_path(fluentd_conf)
else
template_path(config)
end
dest = File.join(STAGING_DIR, config)
render_template(dest, src, template_params({ pkg_type: package_type }))
end
end
end

class LinuxPackageTask < PackageTask
Expand Down
4 changes: 4 additions & 0 deletions fluent-package/templates/etc/logrotate.d/fluentd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
compress
delaycompress
notifempty
<% if pkg_type == 'deb' %>
create 640 _<%= service_name %> _<%= service_name %>
<% else %>
create 640 <%= service_name %> <%= service_name %>
<% end %>
sharedscripts
postrotate
pid=/var/run/<%= package_dir %>/<%= service_name %>.pid
Expand Down
Loading