class FPM::Fry::Plugin::Systemd::Callback
@api private
Public Instance Methods
call(_, package)
click to toggle source
# File lib/fpm/fry/plugin/systemd.rb, line 21 def call(_, package) chroot = FPM::Fry::Chroot.new(package.staging_path) files = chroot.entries('lib/systemd/system') - ['.','..'] valid, invalid = files.partition{|file| VALID_UNITS =~ file } if invalid.any? package.logger.warning("Found #{invalid.size} files in systemd unit path that are no systemd units", files: invalid) end units = valid.grep_v(INSTANTIATED_UNITS) return if units.none? package.logger.info("Added #{units.size} systemd units", units: valid) script_helper.after_install_or_upgrade install(units) script_helper.before_remove_entirely before_remove(units) script_helper.after_remove_entirely after_remove(units) end
Private Instance Methods
after_remove(units)
click to toggle source
# File lib/fpm/fry/plugin/systemd.rb, line 57 def after_remove(units) <<BASH if systemctl is-system-running ; then systemctl daemon-reload systemctl reset-failed #{units.join(' ')} fi BASH end
before_remove(units)
click to toggle source
# File lib/fpm/fry/plugin/systemd.rb, line 49 def before_remove(units) <<BASH if systemctl is-system-running ; then systemctl disable --now #{units.join(' ')} fi BASH end
install(units)
click to toggle source
# File lib/fpm/fry/plugin/systemd.rb, line 37 def install(units) <<BASH if systemctl is-system-running ; then systemctl preset #{units.join(' ')} if systemctl is-enabled #{units.join(' ')} ; then systemctl daemon-reload systemctl restart #{units.join(' ')} fi fi BASH end