Skip to content

Commit

Permalink
Merge pull request #700 from gerbercj/feature/sh_package_bugfixes
Browse files Browse the repository at this point in the history
Feature/sh package bugfixes
  • Loading branch information
jordansissel committed May 20, 2014
2 parents 7a02393 + 469b3a8 commit 22e3a39
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions templates/sh.erb
Expand Up @@ -163,8 +163,10 @@ function run_post_install(){
if [ -r $AFTER_INSTALL ] ; then
chmod +x $AFTER_INSTALL
log "Running post install script"
log $($AFTER_INSTALL)
return $?
output=$($AFTER_INSTALL 2>&1)
errorlevel=$?
log $output
return $errorlevel
fi
return 0
}
Expand Down Expand Up @@ -198,11 +200,20 @@ function revert_symlinks(){
function clean_out_old_releases(){
[ -n "$USE_FLAT_RELEASE_DIRECTORY" ] && return

while [ $(ls -tr "${RELEASES_DIR}" | wc -l) -gt 2 ] ; do
OLDEST_RELEASE=$(ls -tr "${RELEASES_DIR}" | head -1)
log "Deleting old release '${OLDEST_RELEASE}'"
rm -rf "${RELEASES_DIR}/${OLDEST_RELEASE}"
done
if [ -n "$OLD_CURRENT_TARGET" ] ; then
# exclude old 'current' from deletions
while [ $(ls -tr "${RELEASES_DIR}" | grep -v ^$(basename "${OLD_CURRENT_TARGET}")$ | wc -l) -gt 2 ] ; do
OLDEST_RELEASE=$(ls -tr "${RELEASES_DIR}" | grep -v ^$(basename "${OLD_CURRENT_TARGET}")$ | head -1)
log "Deleting old release '${OLDEST_RELEASE}'"
rm -rf "${RELEASES_DIR}/${OLDEST_RELEASE}"
done
else
while [ $(ls -tr "${RELEASES_DIR}" | wc -l) -gt 2 ] ; do
OLDEST_RELEASE=$(ls -tr "${RELEASES_DIR}" | head -1)
log "Deleting old release '${OLDEST_RELEASE}'"
rm -rf "${RELEASES_DIR}/${OLDEST_RELEASE}"
done
fi
}

function print_usage(){
Expand Down

0 comments on commit 22e3a39

Please sign in to comment.