module Bandshell
A key/value store for strings. Right now implemented as disk files.
Functions for dealing with the live image (where it’s mounted, if it’s read-only, etc)
This class can be thought of as a singleton model which retrieves, manipulates, and stores information about the Player received from the Concerto server’s concerto-hardware plugin. For example, it keeps track of screen on/off times.
This is a stateless class which provides a collection of methods for controlling the display. Currently supported control interfaces include:
* DPMS
Constants
- INTERFACES_FILE
The Debian interfaces configuration file we are going to write out.
Public Class Methods
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.
# 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
Get the name of the interface we configured
# File lib/bandshell/netconfig.rb, line 535 def self.configured_interface ifname = ConfigStore.read_config('network_interface', '') if ifname != '' Interface.new(ifname) else nil end end
Read a JSON formatted network configuration from the config store. This instantiates the connection and addressing method classes and returns the instances i.e. cm, am = read_network_config
If no configuration is saved or it is corrupt this returns a default configuration that is somewhat likely to work.
# File lib/bandshell/netconfig.rb, line 447 def self.read_network_config input = ConfigStore.read_config('network_config', '') begin args = JSON.parse(input) rescue # set up some sane defaults if we have no configuration # or it can't be parsed args = { 'connection_method' => 'WiredConnection', 'addressing_method' => 'DHCPAddressing', 'connection_method_args' => { }, 'addressing_method_args' => { } } end connection_method_class = Bandshell.const_get(args['connection_method']) addressing_method_class = Bandshell.const_get(args['addressing_method']) connection_method = connection_method_class.new( args['connection_method_args'] ) addressing_method = addressing_method_class.new( args['addressing_method_args'] ) return [connection_method, addressing_method] end
Save the network configuration to the configuration store. Arguments are instances of connection method and addressing method classes. Throws exception if either one is not valid.
# File lib/bandshell/netconfig.rb, line 480 def self.write_network_config(cm, am) # Check that everything is consistent. If not, we currently throw # an exception, which probably is not the best long term solution. cm.validate am.validate # Serialize our instances as JSON data to be written to the config file. json_data = { 'connection_method' => cm.class.basename, 'connection_method_args' => cm.args, 'addressing_method' => am.class.basename, 'addressing_method_args' => am.args }.to_json # Save the serialized configuration. ConfigStore.write_config('network_config', json_data) end