Class: Arver::InitialConfigAction

Inherits:
Action
  • Object
show all
Defined in:
lib/arver/initial_config_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

#execute_partition, #initialize, #load_key, #needs_target_user?, #new_key_generator, #on_user, #open_keystore, #post_host, #post_partition, #pre_action, #pre_host, #pre_partition, #run_on, #verify?, #verify_key_on_target

Constructor Details

This class inherits a constructor from Arver::Action

Instance Method Details

#post_actionObject



3
4
5
6
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
# File 'lib/arver/initial_config_action.rb', line 3

def post_action
  if LocalConfig.instance.username.empty?
    Log.warn( "Please choose a username using '-u'" )
    return
  end
  local_config = LocalConfig.instance.path
  if File.exist?( local_config )
    Log.warn( "#{local_config} already exists" )
  else
    content = { 'username' => LocalConfig.instance.username }
    f = File.new(local_config, "w")
    f.write(content.to_yaml)
    f.close
  end

  config_path = LocalConfig.instance.config_dir

  if File.exist?( config_path )
    Log.warn( "#{config_path} already exists" )
  else
    Config.instance.users = {
      LocalConfig.instance.username => {
        'slot' => "<the next free luks slot>",
        'gpg'  => "<gpg fingerprint of #{LocalConfig.instance.username}>"
      }
    }
    Config.instance.tree = {
      'default' => {
        'sample_machine' => {
          'address'    => 'foo.bar.com',
          'post_open'  => 'script-after-opening-the-disks.sh',
          'a_disk' => {
            'device' => '/dev/sda'
          }
        }
      }
    }
    Config.instance.save
  end
end