bandshell 1.3 → 1.6

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.
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bandshell/netconfig'
4
+ require 'bandshell/passwords'
4
5
 
5
6
  Bandshell::configure_system_network
7
+ Bandshell::Passwords.set_local_passwords
@@ -27,6 +27,7 @@ class ConcertoConfigServer < Sinatra::Base
27
27
  configure :development do
28
28
  puts 'Bandshell Config Server starting in development mode, port '+
29
29
  settings.port.to_s
30
+ enable :logging, :dump_errors, :raise_errors
30
31
  begin
31
32
  require "sinatra/reloader"
32
33
  register Sinatra::Reloader
@@ -36,6 +37,7 @@ class ConcertoConfigServer < Sinatra::Base
36
37
  puts ' installing the sinatra-contrib gem on your system.'
37
38
  end
38
39
  set :no_netconfig, true
40
+ set :show_exceptions, true
39
41
  end
40
42
 
41
43
  def active_page?(path='')
@@ -386,9 +388,10 @@ class ConcertoConfigServer < Sinatra::Base
386
388
  post '/config_password' do
387
389
  protected!
388
390
 
391
+ @errors = []
389
392
  if params[:newpass] != params[:newpass_confirm]
390
- #write flash notice
391
- redirect '/config_password'
393
+ @errors << 'Please make sure the passwords entered are the same.'
394
+ erb :config_password
392
395
  end
393
396
  Bandshell::ConfigStore.write_config('password', params[:newpass])
394
397
  redirect '/setup'
@@ -397,19 +400,27 @@ class ConcertoConfigServer < Sinatra::Base
397
400
  get '/system_password' do
398
401
  protected!
399
402
  if Bandshell::ConfigStore.config_exists?('system_passwords_changed')
400
- redirect '/setup'
403
+ @errors = []
404
+ @errors << 'The system password has already been set. Please log in via SSH and use the passwd command to change it again.'
405
+ #redirect '/setup' TODO: something better.
406
+ else
407
+ erb :system_password
401
408
  end
402
- erb :system_password
403
409
  end
404
410
 
405
411
  post '/system_password' do
406
412
  protected!
407
- if params[:system_password] != params[:system_password_confirm]
408
- #write flash notice
409
- redirect '/system_password'
413
+ @errors = []
414
+ if Bandshell::ConfigStore.config_exists?('system_passwords_changed')
415
+ @errors << 'The system password has already been set. Please log in via SSH and use the passwd command to change it again.'
416
+ erb :system_password
417
+ elsif params[:system_password] != params[:system_password_confirm]
418
+ @errors << 'Please make sure the passwords entered are the same.'
419
+ erb :system_password
420
+ else
421
+ Bandshell::ConfigStore.write_config('system_password', params[:system_password])
422
+ redirect '/setup'
410
423
  end
411
- Bandshell::ConfigStore.write_config('system_password', params[:system_password])
412
- redirect '/setup'
413
424
  end
414
425
 
415
426
  #Shows uptime,firmware version, and general system and process information
@@ -1,3 +1,11 @@
1
+ <% unless @errors.nil? %>
2
+ <% @errors.each do |error| %>
3
+ <p style="color:red">
4
+ <%= error %>
5
+ </p>
6
+ <% end %>
7
+ <% end %>
8
+
1
9
  <div class="clearfix">
2
10
  <ul class="nav nav-tabs">
3
11
  <li class=<%= "active" if active_page?("setup") %>>
@@ -16,5 +24,8 @@
16
24
  <a href="/system_password">System Passwords</a>
17
25
  </li>
18
26
  <% end %>
27
+ <li class=<%= "active" if active_page?("player_status") %>>
28
+ <a href="/player_status">Player Status</a>
29
+ </li>
19
30
  </ul>
20
31
  </div>
@@ -1,6 +1,27 @@
1
+ <%= erb(:navbar, :layout => false) %>
2
+
3
+ <script type="text/javascript">
4
+ togglespeed=0;
5
+ function toggleProcs() {
6
+ if ($("#proclist").is(":visible")) {
7
+ $("#proclist").hide(togglespeed);
8
+ $("#procexpand").text("expand");
9
+ } else {
10
+ $("#proclist").show(togglespeed);
11
+ $("#procexpand").text("hide");
12
+ }
13
+ togglespeed=700; //after the first time
14
+ }
15
+ $().ready(toggleProcs); //start hidden
16
+ </script>
17
+
18
+ <h1>System Information</h1>
1
19
  <p>System Uptime: <%= Uptime.uptime %></p>
2
- <p>System Processes:</p>
3
- <ul>
20
+ <p>
21
+ System Processes: <%= @proctable.count %>
22
+ (<a id="procexpand" href="#" onclick="toggleProcs(700)">expand</a>)
23
+ </p>
24
+ <ul id="proclist">
4
25
  <% for p in @proctable %>
5
26
  <li>
6
27
  <b>
@@ -10,10 +31,22 @@
10
31
  </li>
11
32
  <% end %>
12
33
  </ul>
34
+
35
+ <h1>Player Configuration</h1>
36
+ <p>
37
+ Screen Name:
38
+ <%= player_info.screen_name %>
39
+ </p>
40
+
41
+ <h1>Display Status</h1>
13
42
  <p>Screen on/off rules:</p>
14
43
  <pre>
15
44
  <%= JSON.pretty_generate(@on_off_rules) %>
16
45
  </pre>
46
+ <p>
47
+ Time Zone:
48
+ <%= player_info.timezone.nil? ? "Not set" : player_info.timezone %>
49
+ </p>
17
50
  <p>
18
51
  Screen scheduled state:
19
52
  <%= player_info.screen_scheduled_on? ? "On" : "Off" %>
@@ -1,11 +1,3 @@
1
- <% unless @errors.nil? %>
2
- <% @errors.each do |error| %>
3
- <p style="color:red">
4
- <%= error %>
5
- </p>
6
- <% end %>
7
- <% end %>
8
-
9
1
  <%= erb(:navbar, :layout => false) %>
10
2
 
11
3
  <div class="default-padding">
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bandshell/config_store'
4
+
5
+ module Bandshell
6
+ module Passwords
7
+ def self.set_local_passwords
8
+ if Bandshell::ConfigStore.config_exists?('system_passwords_changed')
9
+ # if we have changed the passwords, try to restore the shadow file
10
+ # from the configuration store
11
+ restore_shadow
12
+ else
13
+ #if the password has not been changed before during initial setup,
14
+ #read a new one and change passwords accordingly
15
+ system_password = Bandshell::ConfigStore.read_config('system_password', '')
16
+ unless system_password.empty?
17
+ IO.popen("chpasswd", mode='r+') do |io|
18
+ io.puts "root:#{system_password}"
19
+ io.puts "concerto:#{system_password}"
20
+ end
21
+
22
+ if $? == 0
23
+ # remove plain text passwords from config and set flag
24
+ Bandshell::ConfigStore.delete_config('system_password')
25
+ Bandshell::ConfigStore.write_config('system_passwords_changed', 'true')
26
+
27
+ # save shadow file (with password hashes) into config
28
+ save_shadow
29
+ else
30
+ # chpasswd returned nonzero status... do something to indicate error
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def self.save_shadow
37
+ shadow_content = IO.read("/etc/shadow")
38
+ Bandshell::ConfigStore.write_config('shadow_file', shadow_content)
39
+ end
40
+
41
+ def self.restore_shadow
42
+ oldshadow = IO.read("/etc/shadow")
43
+ shadow_content = Bandshell::ConfigStore.read_config('shadow_file', oldshadow)
44
+ IO.write("/etc/shadow", shadow_content)
45
+ end
46
+ end
47
+ end
@@ -1,6 +1,7 @@
1
1
  require 'bandshell/config_store'
2
2
  require 'net/http'
3
3
  require 'json'
4
+ require 'tzinfo'
4
5
 
5
6
  # This class can be thought of as a singleton model which retrieves,
6
7
  # manipulates, and stores information about the Player received from
@@ -11,6 +12,8 @@ module Bandshell
11
12
  attr_accessor :last_update
12
13
  attr_accessor :on_off_rules
13
14
  attr_accessor :shelf_life
15
+ attr_accessor :screen_name
16
+ attr_accessor :timezone # String representation of TZ Location
14
17
 
15
18
  def initialize
16
19
  @last_update = Time.new(0)
@@ -40,6 +43,18 @@ module Bandshell
40
43
  elsif data == :stat_badauth
41
44
  puts "update_player_info: Auth error while retrieving player info."
42
45
  else
46
+ unless data['screen'].nil? or data['screen']['name'].nil?
47
+ @screen_name = data['screen']['name']
48
+ end
49
+ tz_string = data['time_zone']
50
+ unless tz_string.nil? or tz_string.empty?
51
+ begin
52
+ new_tz = TZInfo::Timezone.get(tz_string)
53
+ @timezone = tz_string
54
+ rescue TZInfo::InvalidTimezoneIdentifier => e
55
+ puts "update_player_info: Invalid timezone received."
56
+ end
57
+ end # TZ identifier present
43
58
  new_rules = data['screen_on_off']
44
59
  if new_rules.nil? or !new_rules.is_a? Array
45
60
  puts "update_player_info: Invalid screen on/off rules received."
@@ -55,12 +70,18 @@ module Bandshell
55
70
  # Returns true if the screen should be turned on right now,
56
71
  # according to the latest data recieved from concerto-hardware.
57
72
  # Assumes on_off_rules is either nil or a valid ruleset.
58
- # TODO: Evaluate effects of timezones
59
73
  def screen_scheduled_on?
60
74
  return true if on_off_rules.nil?
61
-
62
75
  results = []
63
- t = Time.now
76
+
77
+ begin
78
+ tz = TZInfo::Timezone.get(timezone) unless timezone.nil?
79
+ rescue TZInfo::InvalidTimezoneIdentifier => e
80
+ puts('screen_scheduled_on?: Invalid Time Zone. Defaulting to NY.')
81
+ end
82
+ tz = TZInfo::Timezone.get('America/New_York') if tz.nil?
83
+
84
+ t = tz.now
64
85
  on_off_rules.each do |rule|
65
86
  rule_active = true
66
87
  rule.each do |key, value|
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.3'
4
+ version: '1.6'
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-06-26 00:00:00.000000000 Z
11
+ date: 2015-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -80,19 +80,36 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tzinfo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Client-side tools for Concerto digital signage
84
98
  email: team@concerto-signage.org
85
99
  executables:
86
- - concerto_netsetup
100
+ - bandshelld_boot
87
101
  - bandshelld
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
105
  - bin/bandshell-timer.rb
106
+ - bin/bandshell-timer.rb.output
92
107
  - bin/bandshelld
93
- - bin/concerto_netsetup
108
+ - bin/bandshelld.output
109
+ - bin/bandshelld_boot
94
110
  - lib/bandshell/application/app.rb
95
111
  - lib/bandshell/application/config.ru
112
+ - lib/bandshell/application/log/development.log
96
113
  - lib/bandshell/application/public/favicon.ico
97
114
  - lib/bandshell/application/public/images/elements/logomark.png
98
115
  - lib/bandshell/application/public/images/layout/pagebg.gif
@@ -150,6 +167,7 @@ files:
150
167
  - lib/bandshell/hardware_api.rb
151
168
  - lib/bandshell/live_image.rb
152
169
  - lib/bandshell/netconfig.rb
170
+ - lib/bandshell/passwords.rb
153
171
  - lib/bandshell/player_info.rb
154
172
  - lib/bandshell/screen_control.rb
155
173
  homepage:
@@ -172,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
190
  version: '0'
173
191
  requirements: []
174
192
  rubyforge_project:
175
- rubygems_version: 2.4.5
193
+ rubygems_version: 2.2.2
176
194
  signing_key:
177
195
  specification_version: 4
178
196
  summary: Concerto Client Tools