Class: Arver::OpenAction

Inherits:
Action
  • Object
show all
Defined in:
lib/arver/open_action.rb

Instance Attribute Summary

Attributes inherited from Action

#generator, #key, #keystore, #slot_of_target_user, #target_list, #target_user

Instance Method Summary collapse

Methods inherited from Action

#load_key, #needs_target_user?, #new_key_generator, #on_user, #open_keystore, #post_action, #pre_action, #run_on, #verify_key_on_target

Constructor Details

#initialize(target_list) ⇒ OpenAction

Returns a new instance of OpenAction.



3
4
5
6
# File 'lib/arver/open_action.rb', line 3

def initialize( target_list )
  super( target_list )
  self.open_keystore
end

Instance Method Details

#execute_partition(partition) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/arver/open_action.rb', line 17

def execute_partition( partition )
  Arver::Log.info( "opening: "+partition.path )
  caller = Arver::LuksWrapper.open( partition )
  unless( caller.execute( key ) )
    if( Arver::LuksWrapper.was_wrong_key?( caller ) )
      Arver::Log.error( "Your key for "+partition.name+" is no longer valid. Maybe it was revoked. skipping." )
    else
      Arver::Log.error( "Aborting: Something went wrong when opening "+partition.name+":\n"+caller.output )
      throw( :abort_action )
    end
  end
end

#post_host(host) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/arver/open_action.rb', line 60

def post_host( host )
  return if host.post_open.nil?
  Arver::Log.info( "Running script: " + host.post_open + " on " + host.name )
  c = Arver::SSHCommandWrapper.create( host.post_open, [] , host, true )
  unless c.execute
    Arver::Log.error( "Aborting: post_open on #{host.name} failed:\n"+c.output )
    throw( :abort_action )
  end
end

#post_partition(partition) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/arver/open_action.rb', line 50

def post_partition( partition )
  return if partition.post_open.nil?
  Arver::Log.info( "Running script: " + partition.post_open + " on " + partition.parent.name )
  c = Arver::SSHCommandWrapper.create( partition.post_open, [] , partition.parent, true )
  unless c.execute
    Arver::Log.error( "Aborting: post_open on #{partition.name} failed:\n"+c.output )
    throw( :abort_action )
  end
end

#pre_host(host) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/arver/open_action.rb', line 30

def pre_host( host )
  return if host.pre_open.nil?
  Arver::Log.info( "Running script: " + host.pre_open + " on " + host.name )
  c = Arver::SSHCommandWrapper.create( host.pre_open, [] , host, true )
  unless c.execute
    Arver::Log.error( "Aborting: pre_open on #{host.name} failed:\n"+c.output )
    throw( :abort_action )
  end
end

#pre_partition(partition) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/arver/open_action.rb', line 40

def pre_partition( partition )
  return if partition.pre_open.nil?
  Arver::Log.info( "Running script: " + partition.pre_open + " on " + partition.parent.name )
  c = Arver::SSHCommandWrapper.create( partition.pre_open, [] , partition.parent, true )
  unless c.execute
    Arver::Log.error( "Aborting: pre_open on #{partition.name} failed:\n"+c.output )
    throw( :abort_action )
  end
end

#verify?(partition) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/arver/open_action.rb', line 8

def verify?( partition )
  if( Arver::LuksWrapper.open?(partition).execute )
    Arver::Log.error( partition.name+" already open. skipping." )
    return false
  end
  return false unless load_key( partition )
  true
end