Class: AethernalAgent::Plex
- Defined in:
- lib/aethernal_agent/plugins/plex/plex.rb
Constant Summary
Constants included from Systemd
Instance Attribute Summary
Attributes inherited from App
#container_settings, #global_options, #manifest, #plugin_path, #user
Attributes included from Errors
Instance Method Summary collapse
- #claim(options = {}) ⇒ Object
- #configure_app_user(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Plex
constructor
A new instance of Plex.
- #install_packages(options = {}) ⇒ Object
- #remove_app_user(options = {}) ⇒ Object
- #uninstall_packages(options = {}) ⇒ Object
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, #unzip
Methods included from 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 = {}) ⇒ Plex
Returns a new instance of Plex.
2 3 4 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 2 def initialize( = {}) super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AethernalAgent::Systemd
Instance Method Details
#claim(options = {}) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 56 def claim( = {}) AethernalAgent.logger.info("Claiming server") ('claim', ) run_command("curl -v -X POST http://127.0.0.1:32400/myplex/claim?token=#{['claim_token']}") AethernalAgent.logger.info("Done claiming server") return create_return_args() end |
#configure_app_user(options = {}) ⇒ Object
22 23 24 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 53 54 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 22 def configure_app_user( = {}) #TODO: Do error handling here. install_packages() # Plex runs automatically after installing so let's stop it. run_command("systemctl daemon-reload") run_command("service plexmediaserver stop") directory("/var/lib/plexmediaserver", owner: self.user) directory("/usr/lib/plexmediaserver", owner: self.user) file("/lib/systemd/system/plexmediaserver.service", action: :delete) result = super() do |opts| container_domain = "#{get_global_config(:container_name)}.#{get_global_config(:hostname)}" write_template(template_path('Preferences.xml.erb'), '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml', opts.merge(domain: container_domain), {owner: self.user}) end return result if result[:errors].present? # We will have to do this after the service files have been created so we can't do this inside the super itself reload_systemd_config start AethernalAgent.logger.debug("Sleeping to wait for Plex server start-up") sleep 30 self.claim(result[:options]) return create_return_args(result[:options]) end |
#install_packages(options = {}) ⇒ Object
6 7 8 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 6 def install_packages( = {}) super() end |
#remove_app_user(options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 17 def remove_app_user( = {}) uninstall_packages() super() end |
#uninstall_packages(options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/aethernal_agent/plugins/plex/plex.rb', line 10 def uninstall_packages( = {}) super() directory("/var/lib/plexmediaserver", action: :delete) directory("/usr/lib/plexmediaserver", action: :delete) end |