Skip to content

Commit

Permalink
Abuse the bandshell timer a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
augustf committed Jun 26, 2015
1 parent 672f128 commit a4cac18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion bin/bandshell-timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Periodically ping the bandshell web app so that background tasks
# may be performed. Called by bandshelld as a daemon.
require "net/http"
require 'bandshell/config_store'

def linestamp
"bandshell-timer.rb ("+Time.now.to_s+"): "
Expand All @@ -21,9 +22,15 @@ def linestamp
puts linestamp + "connecting to bandshell at " + BandshellURL

StatusURI = URI.parse(BandshellURL+"/background-job")

loop do
sleep(5)
#if a system password is stored as a config, we need to restart bandshelld
#to execute chpasswd and clear that config
if Bandshell::ConfigStore.config_exists?('system_password')
system("bandshelld restart")
end

begin
response = Net::HTTP.get_response(StatusURI)
rescue Errno::ECONNREFUSED
Expand Down
2 changes: 2 additions & 0 deletions bin/bandshelld
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require "daemons"
require "bandshell/application/app"
require 'bandshell/config_store'

#if the password has not been changed before during initial setup,
#read a new one and change passwords accordingly
unless Bandshell::ConfigStore.config_exists?('system_passwords_changed')
system_password = Bandshell::ConfigStore.read_config('system_password', '')
unless system_password.empty?
Expand Down
4 changes: 3 additions & 1 deletion lib/bandshell/application/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ def validate_url(url)
end

get '/' do
if concerto_url == ''
if !Bandshell::ConfigStore.config_exists?('system_passwords_changed')
redirect '/system_password'
elsif concerto_url == ''
redirect '/setup'
else
redirect '/player_status'
Expand Down
2 changes: 1 addition & 1 deletion lib/bandshell/application/views/system_password.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= erb(:navbar, :layout => false) %>

<h3>Please change the SSH password for this machine here. Once the password is set, further changes can be made via the command line.</h3>
<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>

<div class="default-padding">
<form method="post">
Expand Down

0 comments on commit a4cac18

Please sign in to comment.