Skip to content

Set variable for password in netconfig.rb #43

@apinter

Description

@apinter

Hi Guys,

Started to play around with Concerto a few days ago, it is awesome, but noticed that it can, but out of the box can't connect to encrypted wireless networks (wpa personal) so I added a field in ../application/views/netsettings.erb which is fine and tried to add an instance variable in ../lib/bandshell/netconfig.rb @pwas:

class WirelessConnection
def initialize(args={})
@SSID = args['ssid'] || ''
@interface_name = args['interface_name'] if args['interface_name']
@wpa_config_file = '/tmp/wpa_supplicant.concerto.conf'
@pwas = args['pwas'] || ''
end

attr_accessor :pwas, :ssid, :interface_name

def config_interface_name
  # If the user has requested a specific interface, use it.
  # Otherwise, just pick the first wlan interface, assuming
  # it works and all wlan interfaces have approximately equal
  # reception. When this assumption is wrong the user must force.
  if @interface_name && @interface_name != ''
    @interface_name
  else
    self.class.interfaces[0].name
  end
end

def validate
  if @ssid == ''
    fail "Need SSID for wireless connection"
  end
end

def safe_assign
  [ :pwas, :ssid, :interface_name ]
end

def write_configs
  # Write a wpa_supplicant.conf file for an unsecured network.
  File.open(@wpa_config_file, 'w') do |wpaconf|
    # long lines, sorry!
    wpaconf.puts "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev"
    wpaconf.puts "network={"
    wpaconf.puts "ssid=\"#{@ssid}\""
    wpaconf.puts "scan_ssid=1"
    wpaconf.puts "key_mgmt=wpa"
    wpaconf.puts "password=#{@pwas}"
    wpaconf.puts "}"
  end
end

def interfaces_lines
  # This links the wpa config to the interfaces file.
  ["wpa-conf #{@wpa_config_file}"]
end

def args
  {
    'interface_name' => @interface_name,
    'ssid' => @ssid
    'pwas' => @pwas
  }
end

This clearly not working, can you please advise where can I set this variable to make sense?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions