bandshell 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
data/bin/concerto_netsetup
CHANGED
@@ -13,13 +13,13 @@ class ConcertoConfigServer < Sinatra::Base
|
|
13
13
|
# push these over to netconfig.rb?
|
14
14
|
# Our list of available physical-layer connection methods...
|
15
15
|
CONNECTION_METHODS = [
|
16
|
-
|
17
|
-
|
16
|
+
Bandshell::WiredConnection,
|
17
|
+
Bandshell::WirelessConnection
|
18
18
|
]
|
19
19
|
# ... and available layer-3 addressing methods.
|
20
20
|
ADDRESSING_METHODS = [
|
21
|
-
|
22
|
-
|
21
|
+
Bandshell::DHCPAddressing,
|
22
|
+
Bandshell::StaticAddressing
|
23
23
|
]
|
24
24
|
|
25
25
|
# Hosts we allow to access configuration without authenticating.
|
@@ -60,7 +60,7 @@ class ConcertoConfigServer < Sinatra::Base
|
|
60
60
|
# password to be considered authorized.
|
61
61
|
def authorized?
|
62
62
|
ip = IPAddress.parse(request.env['REMOTE_ADDR'])
|
63
|
-
password =
|
63
|
+
password = Bandshell::ConfigStore.read_config(
|
64
64
|
'password', 'default'
|
65
65
|
)
|
66
66
|
if LOCALHOSTS.include? ip
|
@@ -75,13 +75,13 @@ class ConcertoConfigServer < Sinatra::Base
|
|
75
75
|
|
76
76
|
# Get our base URL from wherever it may be stored.
|
77
77
|
def concerto_url
|
78
|
-
|
78
|
+
Bandshell::ConfigStore.read_config('concerto_url', '')
|
79
79
|
end
|
80
80
|
|
81
81
|
# Try to figure out what our current IPv4 address is
|
82
82
|
# and return it as a string.
|
83
83
|
def my_ip
|
84
|
-
iface =
|
84
|
+
iface = Bandshell.configured_interface
|
85
85
|
if iface
|
86
86
|
iface.ip
|
87
87
|
else
|
@@ -92,7 +92,7 @@ class ConcertoConfigServer < Sinatra::Base
|
|
92
92
|
# Check if we have something resembling a network connection.
|
93
93
|
# This means we found a usable interface and it has an IPv4 address.
|
94
94
|
def network_ok
|
95
|
-
iface =
|
95
|
+
iface = Bandshell.configured_interface
|
96
96
|
if iface
|
97
97
|
if iface.ip != "0.0.0.0"
|
98
98
|
true
|
@@ -174,7 +174,7 @@ class ConcertoConfigServer < Sinatra::Base
|
|
174
174
|
url = params[:url]
|
175
175
|
if validate_url(url)
|
176
176
|
# save to the configuration store
|
177
|
-
|
177
|
+
Bandshell::ConfigStore.write_config('concerto_url', url)
|
178
178
|
|
179
179
|
# root will now redirect to the proper concerto_url
|
180
180
|
redirect '/screen'
|
@@ -200,7 +200,7 @@ class ConcertoConfigServer < Sinatra::Base
|
|
200
200
|
# is not implemented. This is also how we get away with just having
|
201
201
|
# one instance each of the config classes that are currently selected.
|
202
202
|
begin
|
203
|
-
cm, am =
|
203
|
+
cm, am = Bandshell.read_network_config
|
204
204
|
rescue Errno::ENOENT
|
205
205
|
cm = nil
|
206
206
|
am = nil
|
@@ -275,17 +275,17 @@ class ConcertoConfigServer < Sinatra::Base
|
|
275
275
|
do_assign(amargs, am)
|
276
276
|
|
277
277
|
# Save the configuration file.
|
278
|
-
|
278
|
+
Bandshell.write_network_config(cm, am)
|
279
279
|
|
280
280
|
# Reload network configuration.
|
281
281
|
STDERR.puts "Trying to bring down the interface"
|
282
|
-
if
|
283
|
-
|
282
|
+
if Bandshell.configured_interface
|
283
|
+
Bandshell.configured_interface.ifdown
|
284
284
|
end
|
285
285
|
STDERR.puts "Rewriting configuration files"
|
286
|
-
|
286
|
+
Bandshell::configure_system_network
|
287
287
|
STDERR.puts "Bringing interface back up"
|
288
|
-
|
288
|
+
Bandshell.configured_interface.ifup
|
289
289
|
|
290
290
|
# Back to the network form.
|
291
291
|
redirect '/netconfig' # as a get request
|
@@ -304,7 +304,7 @@ class ConcertoConfigServer < Sinatra::Base
|
|
304
304
|
redirect '/password'
|
305
305
|
end
|
306
306
|
|
307
|
-
|
307
|
+
Bandshell::ConfigStore.write_config('password', params[:newpass])
|
308
308
|
redirect '/setup'
|
309
309
|
end
|
310
310
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
%option{:value=>""}="Auto Select"
|
20
20
|
/ list out available interfaces and their MAC addresses
|
21
21
|
/ preselect one if there was one chosen in config
|
22
|
-
-
|
22
|
+
- Bandshell::WiredConnection.interfaces.each do |iface|
|
23
23
|
%option{:value=>iface.name, :selected=>value_from(connection_method, :interface_name)==iface.name}="#{iface.name} - #{iface.mac}"
|
24
24
|
#WirelessConnection
|
25
25
|
%h3="Wireless Connection Settings (no encryption)"
|
@@ -28,7 +28,7 @@
|
|
28
28
|
%select#interface_name{:name=>"WirelessConnection/interface_name"}
|
29
29
|
%option{:value=>""}="Auto Select"
|
30
30
|
/ same as above but with the wireless interfaces
|
31
|
-
-
|
31
|
+
- Bandshell::WirelessConnection.interfaces.each do |iface|
|
32
32
|
%option{:value=>iface.name, :selected=>value_from(connection_method, :interface_name) == iface.name}="#{iface.name} - #{iface.mac}"
|
33
33
|
%p
|
34
34
|
%label{:for=>"WirelessConnection_ssid"}="SSID"
|
data/lib/bandshell/netconfig.rb
CHANGED
@@ -27,7 +27,7 @@ class Module
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
module
|
30
|
+
module Bandshell
|
31
31
|
# The Debian interfaces configuration file we are going to write out.
|
32
32
|
INTERFACES_FILE='/etc/network/interfaces'
|
33
33
|
|
@@ -459,8 +459,8 @@ module ConcertoConfig
|
|
459
459
|
}
|
460
460
|
end
|
461
461
|
|
462
|
-
connection_method_class =
|
463
|
-
addressing_method_class =
|
462
|
+
connection_method_class = Bandshell.const_get(args['connection_method'])
|
463
|
+
addressing_method_class = Bandshell.const_get(args['addressing_method'])
|
464
464
|
|
465
465
|
connection_method = connection_method_class.new(
|
466
466
|
args['connection_method_args']
|