diff --git a/deploy.sh b/deploy.sh index 4824d0b..e06b707 100755 --- a/deploy.sh +++ b/deploy.sh @@ -149,13 +149,13 @@ function symlink_update() { local src=$1 local dst=$2 - # remove old symlink if [[ -L $dst ]]; then - rm $dst || die "Unable to delete production symlink" + # create new symlink + ln -s $src ${dst}_tmp || die "Unable to create new symlink" + + # replace old symlink + mv -Tf ${dst}_tmp $dst || die "Unable to replace production symlink" fi - - # create new symlink - ln -s $src $dst || die "Unable to create production symlink" } symlink_post_hook(){ @@ -184,7 +184,6 @@ do_prune(){ # Called when script finishes or if user aborts cleanup(){ rm -f $LOCK_FILE || die - popd > /dev/null } handle_sigint(){ @@ -195,6 +194,9 @@ handle_sigint(){ ############## END FUNCTIONS ####################3 +# Catch ctrl-c +trap handle_sigint SIGINT + if [ $# -gt 1 ]; then echo "Bad usage" exit 48 @@ -224,11 +226,7 @@ fi # fix relative paths DIR=$(readlink -f $(dirname "${SETTINGS_FILE}")) echo "${infostar} Working directory: ${DIR}" -pushd ${DIR} > /dev/null - -# Catch ctrl-c -# This should be done after pushd since it calls popd to restore cwd -trap handle_sigint SIGINT +cd ${DIR} # Create release name releasename="${releaseprefix:-release}-`date +%Y%m%d%H%M%S`" @@ -315,10 +313,10 @@ echo " rm $LOCK_FILE" echo "*********************************" echo answer="fail" -until [ "$answer" == "yes" ]; do +until [[ "$answer" = "yes" ]]; do echo -n "${bold}Do you wish to continue?${normal} [${green}yes${normal}/${red}no${normal}] " read answer - if [ "$answer" == "no" ]; then + if [[ "$answer" = "no" ]]; then echo "Aborting." exit 45 fi diff --git a/deploy_settings_example.sh b/deploy_settings_example.sh index 1227fa0..67b307d 100644 --- a/deploy_settings_example.sh +++ b/deploy_settings_example.sh @@ -6,7 +6,7 @@ VCS="git" # All relative paths are relative to the directory this configuration exists in. # A lock file is used to ensure multiple deploys aren't run at the same time. -# LOCK_FILE=deploy.lock +#LOCK_FILE=deploy.lock # Path to an existing working copy (user must checkout/clone the repository # before the first deploy, the deploy script only updates/pulls new revisions) @@ -19,18 +19,18 @@ EXPORT_TARGET=/var/www/site/releases SYMLINK_PATH=/var/www/site/example.com # How many old releases to retain. -# RELEASE_COUNT=8 +#RELEASE_COUNT=8 # File patterns to remove from the export. If you create a custom # `export_post_hook` you must manually call `file_prune` if you need this # feature. -# PRUNE=(o -# ".*\.xcf" -# ) +#PRUNE=(o +# ".*\.xcf" +#) # Sample hook -# update_post_hook(){ -# echo "in overloaded post update hook" -# } +#update_post_hook(){ +# echo "in overloaded post update hook" +#} SETTINGS_FILE_OK=1