summaryrefslogtreecommitdiff
path: root/lib/environment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/environment.rb')
-rw-r--r--lib/environment.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/environment.rb b/lib/environment.rb
index 814e5c0..9338ca5 100644
--- a/lib/environment.rb
+++ b/lib/environment.rb
@@ -6,6 +6,7 @@ ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV']
basedir = File.join(ENV['HOME'], ".opentox")
config_dir = File.join(basedir, "config")
config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml")
+user_file = File.join(config_dir, "users.yaml")
TMP_DIR = File.join(basedir, "tmp")
LOG_DIR = File.join(basedir, "log")
@@ -44,6 +45,21 @@ logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
LOGGER = Logger.new(logfile,'daily') # daily rotation
LOGGER.level = Logger::DEBUG
+if File.exist?(user_file)
+ @@users = YAML.load_file(user_file)
+else
+ FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/users.yaml'), user_file)
+ puts "Please edit #{user_file} and restart your application."
+ exit
+end
+
+begin
+ 0 < @@users[:users].keys.length
+rescue
+ puts "Please edit #{user_file} and restart your application. Create at least one user with password."
+ exit
+end
+
# RDF namespaces
RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
OWL = Redland::Namespace.new 'http://www.w3.org/2002/07/owl#'