Class: AethernalAgent::Radarr

Inherits:
App
  • Object
show all
Defined in:
lib/aethernal_agent/plugins/radarr/radarr.rb

Constant Summary

Constants included from Systemd

Systemd::SYSTEMD_ACTIONS

Instance Attribute Summary

Attributes inherited from App

#container_settings, #global_options, #manifest, #plugin_path, #user

Attributes included from Errors

#global_errors

Instance Method Summary collapse

Methods inherited from App

#app_path, #create_return_args, #ensure_action_options, #extract, #icon_file, #icon_sha, #is_docker_install?, #is_local_install?, #sha_1_hash, #status, #uninstall_packages, #unzip

Methods included from Errors

#add_errors, #get_errors

Methods included from Utils

#apt_running?, #check_manifest, #container_domain, #current_xdg_runtime_dir, #docker_container_name, #get_current_uid, #get_global_config, #global_config_path, #port_is_free, #prepare_test_config, #print_system, #random_port, #random_string, #run_as, #run_command, #run_systemd_plain, #set_global_config, #systemd_text_for_service, #ubuntu_release, #wait_on_apt, #wait_on_file, #wait_on_port

Methods included from Systemd

#create_service_file, #get_systemd_status, #method_missing, #parse_systemd_status_text, #reload_systemd_config, #run_user_systemctl, #service_file_path

Methods included from Filesystem

#aethernal_agent_file, #aethernal_agent_folder, #copy, #directory, #file, #file_settings, #files_folder, #files_path, #home_folder_path, #meta_folder, #meta_path, #set_ownership, #set_permissions, #template_path, #templates_folder, #write_template

Methods included from Apt

#add_apt_ppa, #apt_package, #apt_update, included

Constructor Details

#initialize(options = {}) ⇒ Radarr

Returns a new instance of Radarr.



2
3
4
# File 'lib/aethernal_agent/plugins/radarr/radarr.rb', line 2

def initialize(options = {})
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AethernalAgent::Systemd

Instance Method Details

#configure_app_user(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/aethernal_agent/plugins/radarr/radarr.rb', line 25

def configure_app_user(options = {})
  self.install_packages(options)

  super(options) do |opts|
    @vars = {
      api_key: Digest::SHA256.hexdigest(Time.now.to_i.to_s + "aethernal")[0..32],
      port: opts['port'],
      ssl_port: opts['ssl_port'],
      password: opts['password'],
      user: self.user}

    write_template(template_path('config.xml.erb'),
                   radarr_config_path('config.xml'),
                   @vars,
                   {owner: @vars[:user]})
  end
  # If we run this within the super we have no systemd scripts yet so we need to do this after everything has been setup except the user.
  # We need to start it for the database and migrations to be created
  start

  if wait_on_port(@vars[:port])
    add_user_to_db
  else
    self.add_errors("Radarr never started up, there is probably a configuration error")
  end

  return create_return_args(@vars)
end

#install_packages(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/aethernal_agent/plugins/radarr/radarr.rb', line 6

def install_packages(options = {})
  remove_app_user

  super(options)

  file(app_path, chmod: 711, owner: self.user)
  FileUtils.mv(app_path + "/Radarr", app_path + "/radarr")
  FileUtils.mv(app_path + "/radarr", home_folder_path(File.join("apps")))
  directory(app_path, action: :delete)
end

#remove_app_user(options = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/aethernal_agent/plugins/radarr/radarr.rb', line 17

def remove_app_user(options = {})
  super(options) do |opts|
    directory(home_folder_path("/apps/radarr"), action: :delete)
    directory(home_folder_path("/apps/Radarr"), action: :delete)
    directory(home_folder_path("/.config/Radarr"), action: :delete)
  end
end