bandshell 1.2 → 1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f691eea3256e1bb34482ca43c354cdb4cbd1514
4
- data.tar.gz: 5003147ec2c51c314ef5a81f299ab4305c8610a5
3
+ metadata.gz: 2989fd086430aa0b0d8c829cc7efa755d84dbc25
4
+ data.tar.gz: f57abc11dbec2c79dd7de4aba4a7a5a5e6bbb34e
5
5
  SHA512:
6
- metadata.gz: a062d1067b2244260ef3420da36d560a02f80f32bea1e15531311f95f77e3d9f7542109827e652262320c11d2a755a568b5abfb200e0ef293a6e9f71dfcf6130
7
- data.tar.gz: 57c865c44869c4f64efeb203b646969941ae176d4a1e2a67ec22dfad39405e2deefeec60d18bf6c5d5a61bb109f13ee321145bd999a8412190070aeea0ebb8c2
6
+ metadata.gz: 95285d42380570c16207b27b9c2e097d5bf30dd98d8c55675007d7c2680be6ea62f891d010c18f5be61da1312b5ea66b5a1fe038d9e6080f51d19226ac79b87b
7
+ data.tar.gz: e70736faa3d57667f15ffa9e5a6aa0dd0dc0b64e4064e15a209306b0c055a3046196eea2db1aa1bd43ce62c3cac3de28f841a28dc1f689e1c827517114a08654
@@ -5,6 +5,7 @@
5
5
  # Periodically ping the bandshell web app so that background tasks
6
6
  # may be performed. Called by bandshelld as a daemon.
7
7
  require "net/http"
8
+ require 'bandshell/config_store'
8
9
 
9
10
  def linestamp
10
11
  "bandshell-timer.rb ("+Time.now.to_s+"): "
@@ -21,9 +22,15 @@ end
21
22
  puts linestamp + "connecting to bandshell at " + BandshellURL
22
23
 
23
24
  StatusURI = URI.parse(BandshellURL+"/background-job")
24
-
25
+
25
26
  loop do
26
27
  sleep(5)
28
+ #if a system password is stored as a config, we need to restart bandshelld
29
+ #to execute chpasswd and clear that config
30
+ if Bandshell::ConfigStore.config_exists?('system_password')
31
+ system("bandshelld restart")
32
+ end
33
+
27
34
  begin
28
35
  response = Net::HTTP.get_response(StatusURI)
29
36
  rescue Errno::ECONNREFUSED
data/bin/bandshelld CHANGED
@@ -5,6 +5,19 @@
5
5
  require "rubygems"
6
6
  require "daemons"
7
7
  require "bandshell/application/app"
8
+ require 'bandshell/config_store'
9
+
10
+ #if the password has not been changed before during initial setup,
11
+ #read a new one and change passwords accordingly
12
+ unless Bandshell::ConfigStore.config_exists?('system_passwords_changed')
13
+ system_password = Bandshell::ConfigStore.read_config('system_password', '')
14
+ unless system_password.empty?
15
+ system("echo \"root:#{system_password}\" | chpasswd")
16
+ system("echo \"concerto:#{system_password}\" | chpasswd")
17
+ Bandshell::ConfigStore.delete_config('system_password')
18
+ Bandshell::ConfigStore.write_config('system_passwords_changed', 'true')
19
+ end
20
+ end
8
21
 
9
22
  dir_mode = (ConcertoConfigServer.development? ? :normal : :system)
10
23
 
@@ -18,6 +31,6 @@ timer_argv = ARGV.dup
18
31
  timer_argv << "--" unless timer_argv.include? "--"
19
32
  timer_argv << bandshell_url
20
33
 
21
- Daemons.run(File.join(File.dirname(__FILE__), "bandshell-timer.rb"),
34
+ Daemons.run(File.join(File.dirname(__FILE__), "bandshell-timer.rb"),
22
35
  :log_output=>true, :dir_mode => dir_mode,
23
36
  :ARGV => timer_argv)
@@ -20,7 +20,7 @@ class ConcertoConfigServer < Sinatra::Base
20
20
 
21
21
  # listen on all IPv4 and IPv6 interfaces
22
22
  set :bind, '::'
23
-
23
+
24
24
  # Provide an option to skip network settings when developing
25
25
  set :no_netconfig, false
26
26
 
@@ -33,11 +33,15 @@ class ConcertoConfigServer < Sinatra::Base
33
33
  rescue LoadError
34
34
  puts ' Reloading is not enabled, however.'
35
35
  puts ' You can enable limited app.rb reloading in development by'
36
- puts ' installing the sinatra-contrib gem on your system.'
37
- end
36
+ puts ' installing the sinatra-contrib gem on your system.'
37
+ end
38
38
  set :no_netconfig, true
39
39
  end
40
40
 
41
+ def active_page?(path='')
42
+ request.path_info == '/' + path
43
+ end
44
+
41
45
  def player_info
42
46
  # Note: probably not thread-safe.
43
47
  @@player_info ||= Bandshell::PlayerInfo.new
@@ -45,19 +49,19 @@ class ConcertoConfigServer < Sinatra::Base
45
49
 
46
50
  # push these over to netconfig.rb?
47
51
  # Our list of available physical-layer connection methods...
48
- CONNECTION_METHODS = [
49
- Bandshell::WiredConnection,
50
- Bandshell::WirelessConnection
52
+ CONNECTION_METHODS = [
53
+ Bandshell::WiredConnection,
54
+ Bandshell::WirelessConnection
51
55
  ]
52
56
  # ... and available layer-3 addressing methods.
53
- ADDRESSING_METHODS = [
54
- Bandshell::DHCPAddressing,
55
- Bandshell::StaticAddressing
57
+ ADDRESSING_METHODS = [
58
+ Bandshell::DHCPAddressing,
59
+ Bandshell::StaticAddressing
56
60
  ]
57
61
 
58
62
  # Hosts we allow to access configuration without authenticating.
59
- LOCALHOSTS = [
60
- IPAddress.parse("127.0.0.1"), # ipv4
63
+ LOCALHOSTS = [
64
+ IPAddress.parse("127.0.0.1"), # ipv4
61
65
  IPAddress.parse("::ffff:127.0.0.1"), # ipv6-mapped ipv4
62
66
  IPAddress.parse("::1") # ipv6
63
67
  ]
@@ -78,7 +82,7 @@ class ConcertoConfigServer < Sinatra::Base
78
82
  end
79
83
 
80
84
  # Enforce authentication on actions.
81
- # Calling from within an action will check authentication and return
85
+ # Calling from within an action will check authentication and return
82
86
  # 401 if unauthorized.
83
87
  def protected!
84
88
  unless authorized?
@@ -96,13 +100,13 @@ class ConcertoConfigServer < Sinatra::Base
96
100
  # Check authorization credentials.
97
101
  # Currently configured to check if the REMOTE_ADDR is local and allow
98
102
  # everything if so. This permits someone at local console to configure
99
- # without the need for a password. Others must have the correct
103
+ # without the need for a password. Others must have the correct
100
104
  # password to be considered authorized.
101
105
  def authorized?
102
106
  password = Bandshell::ConfigStore.read_config(
103
107
  'password', 'default'
104
108
  )
105
- if request_is_local?
109
+ if request_is_local?
106
110
  # allow all requests from localhost no questions asked
107
111
  true
108
112
  else
@@ -128,7 +132,7 @@ class ConcertoConfigServer < Sinatra::Base
128
132
  end
129
133
  end
130
134
 
131
- # Try to figure out what our current port is
135
+ # Try to figure out what our current port is
132
136
  # and return it as a string.
133
137
  def my_port
134
138
  settings.port
@@ -153,7 +157,7 @@ class ConcertoConfigServer < Sinatra::Base
153
157
  # Check if we can retrieve a URL and get a 200 status code.
154
158
  def validate_url(url)
155
159
  begin
156
- # this will fail with Errno::something if server
160
+ # this will fail with Errno::something if server
157
161
  # can't be reached
158
162
  uri = URI(url)
159
163
  Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
@@ -164,7 +168,7 @@ class ConcertoConfigServer < Sinatra::Base
164
168
  if response.code != "200"
165
169
  fail
166
170
  end
167
- end
171
+ end
168
172
 
169
173
  # if we get here we have a somewhat valid URL to go to
170
174
  true
@@ -176,7 +180,9 @@ class ConcertoConfigServer < Sinatra::Base
176
180
  end
177
181
 
178
182
  get '/' do
179
- if concerto_url == ''
183
+ if !Bandshell::ConfigStore.config_exists?('system_passwords_changed')
184
+ redirect '/system_password'
185
+ elsif concerto_url == ''
180
186
  redirect '/setup'
181
187
  else
182
188
  redirect '/player_status'
@@ -206,13 +212,13 @@ class ConcertoConfigServer < Sinatra::Base
206
212
  get '/setup' do
207
213
  protected!
208
214
  if network_ok
209
- # Everything's up and running, we just don't know what
215
+ # Everything's up and running, we just don't know what
210
216
  # our URL should be.
211
217
  @url=Bandshell::ConfigStore.read_config('concerto_url')
212
218
  erb :setup
213
219
  else
214
220
  # The network settings are not sane, we don't have an IP.
215
- # Redirect the user to the network configuration page to
221
+ # Redirect the user to the network configuration page to
216
222
  # take care of this.
217
223
  redirect '/netconfig'
218
224
  end
@@ -252,7 +258,7 @@ class ConcertoConfigServer < Sinatra::Base
252
258
  # TODO: clean this up.
253
259
  get '/authenticate.json' do
254
260
  result = {:accepted => 0}
255
- stat= Bandshell::HardwareApi.attempt_to_get_screen_data!
261
+ stat= Bandshell::HardwareApi.attempt_to_get_screen_data!
256
262
  if stat == :stat_success
257
263
  result[:accepted] = 1
258
264
  result[:url] = Bandshell::HardwareApi.screen_url
@@ -287,11 +293,11 @@ class ConcertoConfigServer < Sinatra::Base
287
293
  am = nil
288
294
  end
289
295
 
290
- # view will grab what it can from our existing
296
+ # view will grab what it can from our existing
291
297
  # connection/addressing methods using value_from().
292
- erb :netsettings, :locals => {
293
- :connection_method => cm,
294
- :addressing_method => am
298
+ erb :netsettings, :locals => {
299
+ :connection_method => cm,
300
+ :addressing_method => am
295
301
  }
296
302
  end
297
303
 
@@ -303,7 +309,7 @@ class ConcertoConfigServer < Sinatra::Base
303
309
 
304
310
  # Extract arguments from a set of form data that are intended to go to a
305
311
  # specific network configuration class. These fields have names of the form
306
- # 'ClassName/field_name'; this function returns a hash in the form
312
+ # 'ClassName/field_name'; this function returns a hash in the form
307
313
  # { 'field_name' => 'value } containing the configuration arguments.
308
314
  def extract_class_args(params, target_class)
309
315
  result = { }
@@ -318,7 +324,7 @@ class ConcertoConfigServer < Sinatra::Base
318
324
  end
319
325
 
320
326
  # Set the arguments on an instance of a given configuration class.
321
- # This uses the safe_assign method that should be present in all
327
+ # This uses the safe_assign method that should be present in all
322
328
  # configuration classes to determine which values are allowed to be passed
323
329
  # via form fields (i.e. which ones are subject to validation)
324
330
  def do_assign(params, instance)
@@ -338,14 +344,14 @@ class ConcertoConfigServer < Sinatra::Base
338
344
  # First we find the connection-method and addressing-method classes.
339
345
  cmclass = pick_class(params[:connection_type], CONNECTION_METHODS)
340
346
  fail "Connection method not supported" if cmclass.nil?
341
-
347
+
342
348
  amclass = pick_class(params[:addressing_type], ADDRESSING_METHODS)
343
349
  fail "Addressing method not supported" if amclass.nil?
344
350
 
345
351
  # ... and create some instances of them.
346
352
  cm = cmclass.new
347
353
  am = amclass.new
348
-
354
+
349
355
  # Now given the names of the specific classes the user has chosen,
350
356
  # extract the corresponding form fields.
351
357
  cmargs = extract_class_args(params, cmclass.basename)
@@ -372,30 +378,47 @@ class ConcertoConfigServer < Sinatra::Base
372
378
  redirect '/netconfig' # as a get request
373
379
  end
374
380
 
375
- get '/password' do
381
+ get '/config_password' do
376
382
  protected!
377
- erb :password
383
+ erb :config_password
378
384
  end
379
385
 
380
- post '/password' do
386
+ post '/config_password' do
381
387
  protected!
382
-
388
+
383
389
  if params[:newpass] != params[:newpass_confirm]
384
- # something something error handling something
385
- redirect '/password'
390
+ #write flash notice
391
+ redirect '/config_password'
386
392
  end
387
-
388
393
  Bandshell::ConfigStore.write_config('password', params[:newpass])
389
394
  redirect '/setup'
390
395
  end
391
-
396
+
397
+ get '/system_password' do
398
+ protected!
399
+ if Bandshell::ConfigStore.config_exists?('system_passwords_changed')
400
+ redirect '/setup'
401
+ end
402
+ erb :system_password
403
+ end
404
+
405
+ post '/system_password' do
406
+ protected!
407
+ if params[:system_password] != params[:system_password_confirm]
408
+ #write flash notice
409
+ redirect '/system_password'
410
+ end
411
+ Bandshell::ConfigStore.write_config('system_password', params[:system_password])
412
+ redirect '/setup'
413
+ end
414
+
392
415
  #Shows uptime,firmware version, and general system and process information
393
416
  #Requires ffi, sys-uptime, and sys-proctable gems
394
417
  get '/player_status' do
395
418
  @proctable = ProcTable.ps
396
419
  @on_off_rules = player_info.on_off_rules
397
420
  erb :player_status
398
- end
421
+ end
399
422
 
400
423
  # Should be fetched at a regular interval by the background job
401
424
  # to execute system maintenance functions such as updating configs
@@ -1,10 +1,4 @@
1
- <div class="clearfix">
2
- <ul class="nav nav-tabs">
3
- <li><a href="/setup">Basic Setup</a></li>
4
- <li><a href="/netconfig">Network Settings</a></li>
5
- <li class="active"><a href="/password">Configuration Password</a></li>
6
- </ul>
7
- </div>
1
+ <%= erb(:navbar, :layout => false) %>
8
2
 
9
3
  <div class="default-padding">
10
4
  <form method="post">
@@ -20,4 +14,4 @@
20
14
  <input type="submit" class="btn btn-primary" value="Change Password"></input>
21
15
  </p>
22
16
  </form>
23
- </div>
17
+ </div>
@@ -9,9 +9,6 @@
9
9
  <script src="javascripts/jquery-1.7.2.js"></script>
10
10
  </head>
11
11
  <body>
12
- <%#= render :partial => "elements/topmenu_contents" %>
13
- <%#= render :partial => "elements/render_flash" %>
14
-
15
12
  <div id="main" class="container-fluid">
16
13
 
17
14
  <section class="viewblock">
@@ -0,0 +1,20 @@
1
+ <div class="clearfix">
2
+ <ul class="nav nav-tabs">
3
+ <li class=<%= "active" if active_page?("setup") %>>
4
+ <a href="/setup">Basic Setup</a>
5
+ </li>
6
+
7
+ <li class=<%= "active" if active_page?("netconfig") %>>
8
+ <a href="/netconfig">Network Settings</a>
9
+ </li>
10
+
11
+ <li class=<%= "active" if active_page?("config_password") %>>
12
+ <a href="/config_password">Configuration Password</a>
13
+ </li>
14
+ <% unless Bandshell::ConfigStore.config_exists?('system_passwords_changed') %>
15
+ <li class=<%= "active" if active_page?("system_password") %>>
16
+ <a href="/system_password">System Passwords</a>
17
+ </li>
18
+ <% end %>
19
+ </ul>
20
+ </div>
@@ -1,19 +1,13 @@
1
1
  <script src="/javascripts/network.js"></script>
2
2
 
3
- <div class="clearfix">
4
- <ul class="nav nav-tabs">
5
- <li><a href="/setup">Basic Setup</a></li>
6
- <li class="active"><a href="/netconfig">Network Settings</a></li>
7
- <li><a href="/password">Configuration Password</a></li>
8
- </ul>
9
- </div>
3
+ <%= erb(:navbar, :layout => false) %>
10
4
 
11
5
  <div>
12
6
 
13
7
  <form method="post">
14
8
  <fieldset>
15
9
  <legend><span>Connection Type</span></legend>
16
-
10
+
17
11
  <div class="clearfix">
18
12
  <select id="connection_type" name="connection_type">
19
13
  <!-- list out our available connection methods as options set the html selected flag on the one that is currently selected in the config -->
@@ -21,13 +15,13 @@
21
15
  <option <%= cm==connection_method.class ? 'selected' : '' %> value="<%= cm.basename %>">
22
16
  <%= cm.description %>
23
17
  </option>
24
- <% end %>
18
+ <% end %>
25
19
  </select>
26
20
  </div>
27
21
 
28
22
  <div id="connection">
29
23
  <div id="WiredConnection" class="clearfix">
30
-
24
+
31
25
  <div class="clearfix">
32
26
  <label for="WiredConnection_interface_name">Interface Name</label>
33
27
  <div class="input">
@@ -66,7 +60,7 @@
66
60
 
67
61
  </div>
68
62
  <div class="span6">
69
-
63
+
70
64
  <div class="clearfix">
71
65
  <label for="WirelessConnection_ssid">SSID</label>
72
66
  <div class="input">
@@ -99,7 +93,7 @@
99
93
  <div id="StaticAddressing" class="clearfix">
100
94
  <div class="row-fluid">
101
95
  <div class="span6">
102
-
96
+
103
97
  <div class="clearfix">
104
98
  <label for="StaticAddressing_address">Address</label>
105
99
  <div class="input">
@@ -116,7 +110,7 @@
116
110
 
117
111
  </div><!-- end .span6 -->
118
112
  <div class="span6">
119
-
113
+
120
114
  <div class="clearfix">
121
115
  <label for="StaticAddressing_gateway">Gateway</label>
122
116
  <div class="input">
@@ -144,4 +138,4 @@
144
138
  </div>
145
139
 
146
140
  </form>
147
- </div>
141
+ </div>
@@ -6,13 +6,7 @@
6
6
  <% end %>
7
7
  <% end %>
8
8
 
9
- <div class="clearfix">
10
- <ul class="nav nav-tabs">
11
- <li class="active"><a href="/setup">Basic Setup</a></li>
12
- <li><a href="/netconfig">Network Settings</a></li>
13
- <li><a href="/password">Configuration Password</a></li>
14
- </ul>
15
- </div>
9
+ <%= erb(:navbar, :layout => false) %>
16
10
 
17
11
  <div class="default-padding">
18
12
  <% if @url.empty? %>
@@ -61,4 +55,4 @@
61
55
  </tbody>
62
56
  </table>
63
57
  </div>
64
- </div>
58
+ </div>
@@ -0,0 +1,19 @@
1
+ <%= erb(:navbar, :layout => false) %>
2
+
3
+ <h3>Please change the SSH password for this player here. Once the password is set, further changes can be made via the command line.</h3>
4
+
5
+ <div class="default-padding">
6
+ <form method="post">
7
+ <p>
8
+ <label for="system_password">System SSH Password</label>
9
+ <input class="input-large" name="system_password" type="password"></input>
10
+ </p>
11
+ <p>
12
+ <label for="system_password_confirm">Confirm Password</label>
13
+ <input class="input-large" name="system_password_confirm" type="password"></input>
14
+ </p>
15
+ <p>
16
+ <input type="submit" class="btn btn-primary" value="Change Passwords"></input>
17
+ </p>
18
+ </form>
19
+ </div>
@@ -8,7 +8,7 @@ module Bandshell
8
8
  @@path = nil
9
9
 
10
10
  def self.read_config(name, default='')
11
- initialize_path if not @@path
11
+ initialize_path if not @@path
12
12
  file = File.join(@@path, name)
13
13
  rofile = File.join(@@ropath, name)
14
14
 
@@ -24,14 +24,14 @@ module Bandshell
24
24
  default
25
25
  end
26
26
  end
27
-
27
+
28
28
  #check if a config exists
29
29
  def self.config_exists?(name)
30
30
  initialize_path if not @@path
31
31
  file = File.join(@@path, name)
32
32
  rofile = File.join(@@ropath, name)
33
33
  File.exist?(file) || File.exist?(rofile)
34
- end
34
+ end
35
35
 
36
36
  # Write a config to the read/write configuration location.
37
37
  def self.write_config(name, value)
@@ -43,6 +43,13 @@ module Bandshell
43
43
  end
44
44
  end
45
45
 
46
+ # Delete a config from the filesystem
47
+ def self.delete_config(name)
48
+ initialize_path if not @@path
49
+ file = File.join(@@path, name)
50
+ FileUtils.rm(file)
51
+ end
52
+
46
53
  def self.initialize_path
47
54
  @@ropath = File.join(LiveImage.mountpoint, 'concerto', 'config')
48
55
  if LiveImage.readonly?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandshell
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Concerto Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -138,12 +138,14 @@ files:
138
138
  - lib/bandshell/application/public/stylesheets/sass/views/users.scss
139
139
  - lib/bandshell/application/public/trollface.png
140
140
  - lib/bandshell/application/views/authenticate.erb
141
+ - lib/bandshell/application/views/config_password.erb
141
142
  - lib/bandshell/application/views/main.erb
143
+ - lib/bandshell/application/views/navbar.erb
142
144
  - lib/bandshell/application/views/netsettings.erb
143
- - lib/bandshell/application/views/password.erb
144
145
  - lib/bandshell/application/views/player_status.erb
145
146
  - lib/bandshell/application/views/problem.erb
146
147
  - lib/bandshell/application/views/setup.erb
148
+ - lib/bandshell/application/views/system_password.erb
147
149
  - lib/bandshell/config_store.rb
148
150
  - lib/bandshell/hardware_api.rb
149
151
  - lib/bandshell/live_image.rb