task :symlink_init_d_script do puts "ensuring init_d script is symlinked" run "test -L /etc/init.d/#{application_stub} || #{sudo} ln -s #{script_path}/init_d /etc/init.d/#{application_stub}" end task :symlink_log_dirs do puts "ensuring #{std_log_dir} exists" mkdir_unless_exists( std_log_dir ) puts "setting ownership on #{std_log_dir} & files to #{user}" run "#{sudo} chown -R #{user} #{std_log_dir}" shared_log_dir = "#{shared_dir}/log" puts "ensuring #{shared_log_dir} exists" mkdir_unless_exists( shared_log_dir ) puts "ensuring log dir #{shared_log_dir} is symlinked to #{std_log_dir}" symlink_dir( std_log_dir, shared_log_dir ) puts "setting ownership on #{shared_log_dir} & files to #{user}" run "#{sudo} chown -R #{user} #{shared_log_dir}" puts "ensuring log dir #{web_dir}/log is symlinked to #{std_log_dir}" symlink_dir( std_log_dir, "#{web_dir}/log" ) puts "setting ownership on log dir & files to #{user}" run "#{sudo} chown -R #{user} #{web_dir}/log" puts "removing default #{current_path}/log symlink" run "#{sudo} rm #{current_path}/log" end task :symlink_pid_dirs do std_pid_dir = "#{web_dir}/tmp/pids" shared_pid_dir = "#{shared_dir}/pids" puts "ensuring #{shared_pid_dir} exists" mkdir_unless_exists( shared_pid_dir ) puts "ensuring #{std_pid_dir} exists" mkdir_unless_exists( std_pid_dir ) puts "ensuring pid dir #{std_pid_dir} is symlinked to #{shared_pid_dir}" symlink_dir( shared_pid_dir, std_pid_dir ) puts "setting ownership on #{web_dir}/tmp & files to #{user}" run "#{sudo} chown -R #{user} #{web_dir}/tmp" puts "setting ownership on #{shared_pid_dir} & files to #{user}" run "#{sudo} chown -R #{user} #{shared_pid_dir}" end task :symlink_site_cache_dir do puts "Removing existing symlink from /tmp/cache/sites" run "(test -d #{web_dir}/tmp/cache && #{sudo} rm -rf #{web_dir}/tmp/cache) || echo 'no existing /tmp/cache dir'" puts "Creating /shared/cache/sites dir if needed" run "mkdir -p #{shared_dir}/cache/sites && #{sudo} chown -R #{user} #{shared_dir}/cache" puts "Symlinking /shared/cache into /tmp/" symlink_dir("#{shared_dir}/cache","#{web_dir}/tmp/cache") end task :regenerate_monit do puts "regenerating monit config file" run "(test -d #{web_dir}/config/monit && #{sudo} rm -rf #{web_dir}/config/monit/*) || mkdir -p #{web_dir}/config/monit" run "cd #{web_dir} && ruby script/generate monit" puts "setting permissions & ownership on monit config files" run "#{sudo} chmod 0700 #{web_dir}/config/monit/* && #{sudo} chown root #{web_dir}/config/monit/*" end task :resymlink_monit do std_monit_file = "/etc/monit/conf.d/#{application_stub}" puts "re-symlinking monit config" run "(test -L #{std_monit_file} && #{sudo} rm #{std_monit_file}) || echo 'no existing link'" run "#{sudo} ln -s #{web_dir}/config/monit/monit.`readlink /etc/trigga_config_file | xargs basename`.config #{std_monit_file} " end task :reload_monit do run "#{sudo} monit reload" end task :regenerate_logrotate do puts "regenerating logrotate config file" run "#{sudo} rm #{web_dir}/config/log_rotate/* && cd #{web_dir} && ruby script/generate logrotate" puts "setting permissions & ownership on logrotate config files" run "#{sudo} chmod 0700 #{web_dir}/config/log_rotate/* && #{sudo} chown root #{web_dir}/config/log_rotate/*" end task :resymlink_logrotate do logrotate_config_file = "#{web_dir}/config/log_rotate/log_rotate.#{File.basename(trigga_config_file)}.config" std_logrotate_file = "/etc/logrotate.d/#{application_stub}" puts "re-symlinking logrotate config" run "(test -L #{std_logrotate_file} && #{sudo} rm #{std_logrotate_file}) || echo nothing to remove" run "#{sudo} ln -s #{web_dir}/config/log_rotate/log_rotate.`readlink /etc/trigga_config_file | xargs basename`.config #{std_logrotate_file} " end task :chown_entire_project_dir do puts "chowning entire #{application_stub} dir to #{user}" run "#{sudo} chown -R #{user} #{deploy_to}" end