From 1a3110b32cf8303f5e9fd253fc7a3f25c26571a6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 1 Dec 2015 12:31:49 +0000 Subject: [PATCH] Move if files exist --- src/freedombone-image | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/freedombone-image b/src/freedombone-image index 088ac780..9b5bfbab 100755 --- a/src/freedombone-image +++ b/src/freedombone-image @@ -239,11 +239,27 @@ if [ ${#imgfiles[@]} -eq 0 ]; then exit 2 fi -mv build/${PROJECT_NAME}*.bz2 ${CURR_DIR} -mv build/${PROJECT_NAME}*.img ${CURR_DIR} -mv build/${PROJECT_NAME}*.sig ${CURR_DIR} -mv build/${PROJECT_NAME}*.vdi ${CURR_DIR} -mv build/${PROJECT_NAME}*.qcow2 ${CURR_DIR} +no_of_files=$(ls -afq build/${PROJECT_NAME}*.bz2 | wc -l) +if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.bz2 ${CURR_DIR} +fi +no_of_files=$(ls -afq build/${PROJECT_NAME}*.img | wc -l) +if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.img ${CURR_DIR} +fi +no_of_files=$(ls -afq build/${PROJECT_NAME}*.sig | wc -l) +if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.sig ${CURR_DIR} +fi +no_of_files=$(ls -afq build/${PROJECT_NAME}*.vdi | wc -l) +if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.vdi ${CURR_DIR} +fi +no_of_files=$(ls -afq build/${PROJECT_NAME}*.qcow2 | wc -l) +if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.qcow2 ${CURR_DIR} +fi + rm -rf ${BUILD_DIR} cd ${CURR_DIR}