Skip to content

Commit

Permalink
* lib/parkplace.rb: check for sqlite3_api to avoid problems with the…
Browse files Browse the repository at this point in the history
… pure Ruby SQLite3 binding. THANK THAT MENTALGUY.

 * bin/parkplace: allow admin to be deleted.
  • Loading branch information
_why committed May 4, 2006
1 parent 701e0dc commit 2da363f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/parkplace
Expand Up @@ -57,15 +57,16 @@ ParkPlace::Models::Base.establish_connection(options.database)
ParkPlace::Models::Base.logger = Logger.new('camping.log') if $DEBUG
ParkPlace.create

if ParkPlace::Models::User.count == 0
num_users = ParkPlace::Models::User.count
if num_users == 0
puts "** No users found, creating the `admin' user."
ParkPlace::Models::User.create :login => "admin", :password => DEFAULT_PASSWORD,
:email => "admin@parkplace.net", :key => "44CF9590006BF252F707", :secret => DEFAULT_SECRET,
:activated_at => Time.now, :superuser => 1
end

admin = ParkPlace::Models::User.find_by_login "admin"
if admin.password == hmac_sha1( DEFAULT_PASSWORD, admin.secret )
if num_users == 1 and admin and not admin.password == hmac_sha1( DEFAULT_PASSWORD, admin.secret )
puts "** Please login in with `admin' and password `#{DEFAULT_PASSWORD}'"
puts "** You should change the default password or delete the admin at soonest chance!"
end
Expand Down
8 changes: 8 additions & 0 deletions lib/parkplace.rb
Expand Up @@ -71,6 +71,14 @@ def config(options)
end
options.storage_dir = File.expand_path(options.storage_dir || 'storage', options.parkplace_dir)
options.database ||= {:adapter => 'sqlite3', :database => File.join(options.parkplace_dir, 'park.db')}
if options.database[:adapter] == 'sqlite3'
begin
require 'sqlite3_api'
rescue LoadError
puts "!! Your SQLite3 adapter isn't a compiled extension."
abort "!! Please check out http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3 for tips."
end
end
ParkPlace::STORAGE_PATH.replace options.storage_dir
end
def serve(host, port)
Expand Down

0 comments on commit 2da363f

Please sign in to comment.