Class: ScoutAgent::Assignment::Update

Inherits:
ScoutAgent::Assignment show all
Defined in:
lib/scout_agent/assignment/update.rb

Overview

Invoke with:

sudo scout_agent update

This command rewrites the current configuration file. As such, it has two main uses. First, you can run this command to load the current file, pass some switches to change settings, and it will save the changes like a text editor would. It’s also useful when an updated version of the agent includes new options you would like to have added to your existing file.

Instance Attribute Summary

Attributes inherited from ScoutAgent::Assignment

#group, #other_args, #switches, #user

Instance Method Summary collapse

Methods inherited from ScoutAgent::Assignment

choose_group, choose_user, #initialize, plan, #prepare_and_execute

Methods included from Tracked

#clear_status, #force_status_database_reload, #status, #status_database, #status_log

Constructor Details

This class inherits a constructor from ScoutAgent::Assignment

Instance Method Details

#executeObject

Runs the update command.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/scout_agent/assignment/update.rb', line 19

def execute
  begin
    Plan.config_file.unlink
    puts "Identification file '#{Plan.config_file}' removed."
  rescue Errno::EACCES
    abort_with_sudo_required
  end
  if Plan.write_default_config_file
    puts "Identification file '#{Plan.config_file}' replaced."
  else
    if Plan.config_file.exist?
      puts "Identification file '#{Plan.config_file}' exists.  Skipped."
    else
      abort_with_sudo_required
    end
  end
end