From f24c6790ea294f23e464c5d8fc95027e217aacbc Mon Sep 17 00:00:00 2001 From: Liam Whalen Date: Sat, 19 Jul 2014 17:18:17 -0700 Subject: [PATCH] Create relative paths for local file storage Currently, when deploying, the local files used to deploy to the server are stored in the same directory. When there are files that have the same name, the last file to be deployed is the only one present in the directory because it overwrites the previous files with the same name. This commit creates a temporary directory with the relative path of the filename appended to the end of the temporary directory. Signed-off-by: Liam Whalen --- deployment/git-deploy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/git-deploy.sh b/deployment/git-deploy.sh index 014ea8d..7706d4d 100755 --- a/deployment/git-deploy.sh +++ b/deployment/git-deploy.sh @@ -131,7 +131,7 @@ function deployfile() { TEMPFILE=`create_tmp_file $TMP_DIR $FILENAME` git --git-dir $REPO show $REMOTE/$BRANCH:$RELATIVE_PATH/$FILENAME > $TEMPFILE - + echo "git --git-dir $REPO show $REMOTE/$BRANCH:$RELATIVE_PATH/$FILENAME > $TEMPFILE" if [[ $PROD_SERVERS =~ " `echo $HOST | cut -d '.' -f 1` " ]] then echo "Cannot deploy `basename $TEMPFILE` to $HOST while testing. Please use another server" @@ -196,9 +196,7 @@ fi #last server that gets translated into an unwanted _. We need to sort the servers, so that they are used in a consistent manner for tracking #deployment HOST_LIST_FOR_DIR_NAME=`echo $HOST_LIST | tr ' ' '\n' | sort | while read SORTED_HOST_LIST ; do get_hostname $SORTED_HOST_LIST ; done | tr '\n' '_' | { read SORTED_HOST_LIST; echo ${SORTED_HOST_LIST%?}; }` -TMP_DIR='/tmp/'$BRANCH'/'$HOST_LIST_FOR_DIR_NAME'/'`date +%Y_%m_%d_%H_%M_%S` -mkdir -p $TMP_DIR if [[ -z "$SYNC" ]] then @@ -230,6 +228,8 @@ do BASE_PATH=`find_base_path $RELATIVE_PATH $DEPLOY_HOST` if [[ $BASE_PATH ]] then + TMP_DIR='/tmp/'$BRANCH'/'$HOST_LIST_FOR_DIR_NAME'/'`date +%Y_%m_%d_%H_%M_%S`'/'$RELATIVE_PATH + mkdir -p $TMP_DIR deployfile $REMOTE $BRANCH $BASE_PATH $RELATIVE_PATH $FILENAME $TMP_DIR $DEPLOY_HOST else echo "Could not deploy $FILENAME to $DEPLOY_HOST because no mapping could be found in $PATHMAP_FILE or any host specific pathmap files" >&2 -- 2.3.6