Class: Helpers::NewSystemd

Inherits:
NewFile
  • Object
show all
Defined in:
lib/spior/helpers.rb

Overview

Class NewSystemd Used to create a systemd service

Example:

require Helpers string = <<EOF

Description
Service

Type=simple

Installation

WantedBy = EOF new_systemd = Helpers::NewSystemd.new(string, “tor.service”) new_systemd.add

Instance Method Summary collapse

Methods inherited from NewFile

#perm

Constructor Details

#initialize(string, name) ⇒ NewSystemd

Method #new

Parameters:

  • string = the string of for whole content file

  • name = the name of the service (e.g: tor.service)



114
115
116
117
118
# File 'lib/spior/helpers.rb', line 114

def initialize(string, name)
  super
  @systemd_dir = search_systemd_dir
  @dest = "#{@systemd_dir}/#{@name}"
end

Instance Method Details

#addObject

Method #add Create a temporary file and move the service @name to the systemd directory



123
124
125
126
127
# File 'lib/spior/helpers.rb', line 123

def add
  @systemctl = Helpers::Exec.new('systemctl')
  super
  @systemctl.run('daemon-reload')
end