Method: Wildcloud::Keeper::Runtime#write_system_configuration

Defined in:
lib/wildcloud/keeper/runtime.rb

#write_system_configuration(options) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/wildcloud/keeper/runtime.rb', line 158

def write_system_configuration(options)
  root = options[:root_path]

  interfaces = ERB.new(File.read(File.expand_path('../templates/interfaces', __FILE__))).result(binding)
  interfaces_path = File.join(root, 'etc', 'network', 'interfaces')
  FileUtils.mkdir_p(File.dirname(interfaces_path))
  File.open(interfaces_path, 'w') { |file| file.write(interfaces) }

  if options[:build]
    FileUtils.mkdir_p(File.join(root, 'root', '.ssh'))
    FileUtils.cp(File.expand_path('~/.ssh/id_rsa'), File.join(root, 'root', '.ssh', 'id_rsa'))
    FileUtils.cp(File.expand_path('~/.ssh/id_rsa.pub'), File.join(root, 'root', '.ssh', 'id_rsa.pub'))

    File.open(File.join(root, 'root', 'build.yml'), 'w') { |file| file.write(YAML::dump(options)) }
  end
end