Created
March 3, 2011 19:01
-
-
Save gordonknoppe/853289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after 'deploy:update_code', 'magento-snapshot:initialize' | |
namespace :magento-snapshot do | |
desc "Initialize snapshot directories" | |
task :initialize, :roles => [:app] do | |
# Create snapshot directory | |
run "mkdir -p #{shared_path}/snapshot" | |
# Remove existing snapshot dir in case it is in the release path | |
run "rm -Rf #{release_path}/snapshot" | |
# Link shared snapshot to release | |
run "ln -nfs #{shared_path}/snapshot #{release_path}/snapshot" | |
# Download latest snapshot.php to /shell | |
if !remote_file_exists?("#{release_path}/shell/snapshot.php") | |
run "wget -P #{release_path}/shell --no-check-certificate -q https://github.com/guidance/magento-shell-tools/raw/master/shell/snapshot.php" | |
end | |
# Install crontab if necessary | |
run "set -f; | |
cronentry='0 0 * * * #{release_path}/shell/snapshot.php'; | |
if crontab -l &>/dev/null; | |
then | |
if crontab -l | grep -q '#{release_path}/shell/snapshot.php'; | |
then | |
echo 'Cron job detected, not updating crontab'; | |
else | |
echo 'Cron job not detected, installing entry in crontab'; | |
echo -e "`crontab -l`\n$cronentry" | crontab -; | |
fi; | |
else | |
echo 'No crontab found for user, installing new crontab with entry'; | |
echo $cronentry | crontab -; | |
fi; | |
set +f" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment