Skip to content

Commit

Permalink
Add option --deb-systemd-path
Browse files Browse the repository at this point in the history
This option will allow you to override the path within the staging directory
systemd service files are moved to in debian packages.

On some systems systemd should not go in the hardcoded /lib/systemd/system but
in /usr/lib/systemd/system instead. Many systems have the both symlinked, but
not all so assuming /lib/systemd/system can be dangerous.

Signed-off-by: Reinier Schoof <[email protected]>
  • Loading branch information
skoef committed Jun 26, 2024
1 parent 9d3d96a commit 5092c5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ class FPM::Package::Deb < FPM::Package
next File.expand_path(file)
end

option "--systemd-path", "FILEPATH", "Relative path to the systemd service directory",
:default => "lib/systemd/system" do |file|
next file.gsub(/^\/*/, '')
end

option "--systemd-enable", :flag , "Enable service on install or upgrade", :default => false

option "--systemd-auto-start", :flag , "Start service after install or upgrade", :default => false
Expand Down Expand Up @@ -518,7 +523,7 @@ def output(output_path)
attributes[:deb_systemd] = []
attributes.fetch(:deb_systemd_list, []).each do |systemd|
name = File.basename(systemd, ".service")
dest_systemd = staging_path("lib/systemd/system/#{name}.service")
dest_systemd = staging_path(File.join(attributes[:deb_systemd_path], "#{name}.service"))
mkdir_p(File.dirname(dest_systemd))
FileUtils.cp(systemd, dest_systemd)
File.chmod(0644, dest_systemd)
Expand Down Expand Up @@ -628,7 +633,7 @@ def output(output_path)

attributes.fetch(:deb_systemd_list, []).each do |systemd|
name = File.basename(systemd, ".service")
dest_systemd = staging_path("lib/systemd/system/#{name}.service")
dest_systemd = staging_path(File.join(attributes[:deb_systemd_path], "#{name}.service"))
mkdir_p(File.dirname(dest_systemd))
FileUtils.cp(systemd, dest_systemd)
File.chmod(0644, dest_systemd)
Expand Down

0 comments on commit 5092c5f

Please sign in to comment.