scripts/webapp.rb in standup-0.3.9 vs scripts/webapp.rb in standup-0.3.10
- old
+ new
@@ -21,11 +21,11 @@
exec "git clone git@github.com:#{params.github_user}/#{params.github_repo}.git #{scripts.webapp.app_path}"
end
bootstrap_db
- sudo "chown -R nobody:nogroup #{scripts.webapp.app_path}"
+ sudo "chown -R www-data:www-data #{scripts.webapp.app_path}"
with_processed_file script_file('webapp.conf') do |file|
scripts.passenger.add_server_conf file, "#{params.name}.conf"
end
end
@@ -36,10 +36,16 @@
def db_name
"#{params.name}_#{params.rails_env}"
end
+ def db
+ return scripts.postgresql if scripts.setup.has_script? 'postgresql'
+ return scripts.mysql if scripts.setup.has_script? 'mysql'
+ nil
+ end
+
protected
def ensure_github_access
return unless exec('ssh -o StrictHostKeyChecking=no git@github.com') =~ /Permission denied \(publickey\)/
@@ -55,16 +61,11 @@
exec('hostname').strip,
exec('cat ~/.ssh/id_rsa.pub').strip
end
def bootstrap_db
- unless scripts.postgresql.exec_sql("select * from pg_user where usename = 'webapp'") =~ /1 row/
- scripts.postgresql.exec_sql "create user webapp with password 'webapp'"
- end
-
- unless scripts.postgresql.exec_sql("select * from pg_database where datname = '#{db_name}'") =~ /1 row/
- scripts.postgresql.exec_sql "create database #{db_name} with owner webapp"
-
+ db.create_user 'webapp', 'webapp'
+ if db.create_database db_name, 'webapp'
in_dir scripts.webapp.app_path do
sudo 'bundle install'
exec "RAILS_ENV=#{params.rails_env} rake db:schema:load"
exec "RAILS_ENV=#{params.rails_env} rake db:seed"
end