From d931a4b466a8c63022442e0bcb38c59b007733a8 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 11 Nov 2013 18:03:40 -0500 Subject: [PATCH] Most recent version of build.sh --- build.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 233c5d8..00ff1e0 100755 --- a/build.sh +++ b/build.sh @@ -4,19 +4,63 @@ if [ -e /run/media/$USER/* ]; then # Build the .xo file + echo 'Found external device.' + echo 'Building xo file...' ./setup.py dist_xo file=dist/*.xo + $(echo $file | cut -f1 -d-) # Check if the file already exists if [ -e /run/media/$USER/*/$file ]; then + echo 'Removing version on device...' rm /run/media/$USER/*/$file - fi + fi # Move the new file onto the external device + echo 'Moving xo file to device...' mv $file /run/media/$USER/*/ - rm -rf dist/ + echo 'Cleaning up...' + rm -r dist/ + +# Notify the user a device was not found +else + echo 'No external device found.' + echo 'Building xo file...' + ./setup.py dist_xo + file=dist/*.xo + activity=$(echo $(echo $file | cut -f1 -d-) | cut -f2 -d/) + + # Check if there is a current version of the xo file in your directory + if [ -e ./$activity-*.xo ]; then + # Prompt the user if they would like to replace the file or not + echo -n 'Would you like to replace the current xo file? [y/n]: ' + read answer - # Notify the user a device was not found + # If the user wants to replace the file, replace it + if [ "$answer" == "y" ]; then + echo 'Removing previous version...' + rm ./$activity-*.xo + mv dist/* ./ + + # If the user does not want to replace the file, + # save the old one and create the new file + elif [ "$answer" == "n" ]; then + old=$activity-*.xo + mv ./$old ./$activity.old.xo + mv ./$file ./$activity.new.xo + + else + echo 'Invalid input.' + echo 'Aborting.' + rm -r dist/ + exit 1 + fi else - echo 'No external device found.' + mv dist/* ./ + fi + + echo 'Cleaning up...' + rm -r dist/ fi + +echo 'Finished!'