summaryrefslogtreecommitdiff
path: root/script/logout_phones
diff options
context:
space:
mode:
Diffstat (limited to 'script/logout_phones')
-rwxr-xr-xscript/logout_phones29
1 files changed, 29 insertions, 0 deletions
diff --git a/script/logout_phones b/script/logout_phones
new file mode 100755
index 0000000..2a1f266
--- /dev/null
+++ b/script/logout_phones
@@ -0,0 +1,29 @@
+#! /usr/bin/env ruby
+
+begin
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require APP_PATH
+
+begin
+ Rails.application.require_environment!
+rescue ActiveRecord::AdapterNotSpecified => e
+ error "No such Rails environment: \"#{Rails.env}\"."
+ exit 1
+end
+
+phones = Phone.where(:nightly_reboot => true).each do |phone|
+ if ! phone.user_logout
+ $stderr.puts "#{phone.id} #{phone.mac_address} - #{phone.errors.messages.inspect}"
+ end
+end
+
+rescue SignalException => e
+ $stderr.print "#{e.class.to_s}"
+ $stderr.print " (Signal #{e.signo.to_s})" if e.respond_to?(:signo) && e.signo
+ $stderr.puts ""
+ exit 130
+end
+
+exit 0