summaryrefslogtreecommitdiff
path: root/script/logout_phones
blob: 2a1f266b84b49efed5e2a80a2891acfefdd1ac77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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