Class: ScoutAgent::Assignment::Reset
- Inherits:
-
ScoutAgent::Assignment
- Object
- ScoutAgent::Assignment
- ScoutAgent::Assignment::Reset
- Defined in:
- lib/scout_agent/assignment/reset.rb
Instance Attribute Summary
Attributes inherited from ScoutAgent::Assignment
#group, #other_args, #switches, #user
Instance Method Summary collapse
Methods inherited from ScoutAgent::Assignment
#initialize, #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
#execute ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 55 56 57 58 59 60 61 62 63 |
# File 'lib/scout_agent/assignment/reset.rb', line 7 def execute agent = IDCard.new(:lifeline) if agent.pid_file.exist? abort_with_agent_running end puts "Reset Your Agent" puts "================" puts print <<-END_WARNING.trim.to_question This is a dangerous operation that will remove configuration and data files. Are you absolutely sure you wish to remove this data (yes/no)? END_WARNING unless gets.to_s.strip.downcase == "yes" abort_with_cancel end puts puts "Resetting..." if not Plan.config_file.exist? puts <<-END_CONFIG_FILE Identification file '#{Plan.config_file}' doesn't exist. Skipped. END_CONFIG_FILE else begin Plan.config_file.unlink puts "Identification file '#{Plan.config_file}' removed." rescue Errno::EACCES # don't have permission (Plan.config_file) end end %w[db_dir pid_dir log_dir].each do |path| dir = Plan.send(path) if not dir.exist? puts "Directory '#{dir}' doesn't exist. Skipped." else begin dir.rmtree puts "Directory '#{dir}' removed." rescue Errno::EACCES # don't have permission (dir) end end end puts "Done." puts puts <<-END_START_INSTRUCTIONS.trim This agent is reset. You can prepare it for use again at anytime with: sudo #{$PROGRAM_NAME} identify END_START_INSTRUCTIONS end |