#################################################################
#################################################################
#
# This is a sample Capistrano deployment recpie for use with
# deploying PHP applications. For more information please visit:
# 
# http://www.lengelzigich.com
# http://www.capify.org
#
# (c) 2008 Clayton Lengel-Zigich
#
#################################################################
#################################################################

set :application, "app"
set :repository,  "http://www.mysubversionrepo.tld/helloworld/trunk/"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/var/www/vhosts/helloworld.tld/httpdocs/#{application}"
set :document_root, "/var/www/vhosts/helloworld.tld/httpdocs/current"

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
set :scm, :subversion
set :scm_username, "cap" #if http
set :scm_password, "password" #if http
set :scm_checkout, "export"


# SSH Settings
set :user, "clz"
set :password, "password"
set :use_sudo, false
set :ssh_options, {:forward_agent => true}

role :app, "127.0.0.1"
role :web, "127.0.0.1"
role :db,  "127.0.0.1", :primary => true


# We need to over write a lot of the core functionality here
# since we don't need migrations, lots of the symlink stuff
# and server restarting.

# This is strictly for PHP deploys
namespace :deploy do
  task :update do
    update_code
    symlink
  end

  task :finalize_update do
    run "chmod -R g+w #{releases_path}/#{release_name}"
  end

  task :symlink do
    run "ln -nfs #{current_release} #{deploy_to}/#{current_dir}"
    run "ln -nfs #{deploy_to}/#{current_dir} #{document_root}"
  end

  task :migrate do
    # nothing
  end

  task :restart do
    # nothing
  end
end

# Now we can get back into some regular recipe stuff

task :after_symlink do
  # sync up the images and other static content
  run "ln -nsf #{shared_path}/images #{document_root}/images"
end