Method: Bandshell.configure_system_network

Defined in:
lib/bandshell/netconfig.rb

.configure_system_networkObject

This reads a JSON configuration file on STDIN and writes the interfaces file. Also the classes instantiated will have a chance to write out any auxiliary files needed.



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/bandshell/netconfig.rb', line 501

def self.configure_system_network
  connection_method, addressing_method = read_network_config

  ifname = connection_method.config_interface_name

  # squirrel away the name of the interface we are configuring
  # This will be useful later for getting network status information.
  ConfigStore.write_config('network_interface', ifname)

  # Write the /etc/network/interfaces file.
  File.open(INTERFACES_FILE, 'w') do |f|
    f.puts "# Concerto Live network configuration"
    f.puts "# Generated by netconfig.rb"
    f.puts "# Changes will be lost on reboot"
    f.puts "auto lo"
    f.puts "iface lo inet loopback"
    f.puts ""
    f.puts "auto #{ifname}"
    f.puts "iface #{ifname} inet #{addressing_method.addressing_type}"

    addressing_method.interfaces_lines.each do |line|
      f.puts "\t#{line}"
    end

    connection_method.interfaces_lines.each do |line|
      f.puts "\t#{line}"
    end
  end

  # Write auxiliary configuration files.
  connection_method.write_configs
end