Class: PleaseRun::Platform::SystemdUser
- Defined in:
- lib/pleaserun/platform/systemd-user.rb
Overview
The platform implementation for systemd user services.
Instance Method Summary collapse
Methods inherited from Base
#all_environment_variables, #default_file, #initialize, #log_path, #log_path_stderr, #log_path_stdout, #parsed_environment_variables, #platform, #render, #render_template, #safe_filename, #sysconfig_file, #template_path
Methods included from MustacheMethods
#escaped, #escaped_args, #quoted, #shell_args, #shell_continuation, #shell_quote
Methods included from Configurable
#configurable_setup, included, #validate
Constructor Details
This class inherits a constructor from PleaseRun::Platform::Base
Instance Method Details
#environment_data ⇒ Object
def files
33 34 35 |
# File 'lib/pleaserun/platform/systemd-user.rb', line 33 def environment_data ENV.collect { |k,v| "#{k}=#{v}" }.join("\n") end |
#files ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pleaserun/platform/systemd-user.rb', line 14 def files begin # TODO(sissel): Make it easy for subclasses to extend validation on attributes. insist { program } =~ /^\// rescue Insist::Failure raise PleaseRun::Configurable::ValidationError, "In systemd, the program must be a full path. You gave '#{program}'." end if !File.directory?(home) raise PleaseRun::Configurable::ValidationError, "HOME (#{home}) is not a directory. Cannot continue." end return Enumerator::Generator.new do |enum| enum.yield(safe_filename("{{{home}}}/.config/systemd/user/{{{ name }}}.environment"), environment_data) enum.yield(safe_filename("{{{home}}}/.config/systemd/user/{{{ name }}}.service"), render_template("program.service")) enum.yield(safe_filename("{{{home}}}/.config/systemd/user/{{{ name }}}-prestart.sh"), render_template("prestart.sh"), 0755) if prestart end end |
#home ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/pleaserun/platform/systemd-user.rb', line 6 def home @home ||= ENV["HOME"] if @home.nil? || @home.empty? raise PleaseRun::Configurable::ValidationError, "As a normal user (not root), I need to know where your home directory is, but the HOME environment variable seems to be not set." end @home end |
#install_actions ⇒ Object
37 38 39 |
# File 'lib/pleaserun/platform/systemd-user.rb', line 37 def install_actions return ["systemctl --user daemon-reload"] end |