set :application, "mydomain.com"

# source control
set :scm, :git
set :branch, 'master'
set :scm_verbose, true
set :repository, "git@mydomain.com:myapp"
set :deploy_via, :copy
#set :copy_strategy, :export

# source control - attempt to use the default deployment strat
#set :repository, "file:///home/git/repositories/myapp.git"
#set :local_repository, "git@mydomain.com:myapp"
#set :use_sudo, true
#set :scm_username, "git"

# deployment path
set :deploy_to, "/srv/www/rails/#{application}"

# servers and roles
set :domain, "mydomain.com" # just a helper for below
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run

default_run_options[:pty] = true

# server login credentials
set :user, "thedeeno"
set :ssh_options, { :forward_agent => true } # allow ssh to use ssh keys in agent
# this doesn't appear to work as I still get
# prompted for a password.

# misc
set :server_name, "mydomain.com"
set :server_alias, "*.mydomain.com"

namespace :deploy do

task :start do
run "/etc/init.d/apache2 start"
end

task :stop do
run "/etc/init.d/apache2 stop"
end

task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end

task :symlinks do
# link database.yml
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
end

after 'deploy:update_code', 'deploy:symlinks'