Skip to content

Instantly share code, notes, and snippets.

@GiacomoManzoli
Created February 6, 2019 15:13
Show Gist options
  • Select an option

  • Save GiacomoManzoli/0c03029f4a5475de25e9e9f3e72839bd to your computer and use it in GitHub Desktop.

Select an option

Save GiacomoManzoli/0c03029f4a5475de25e9e9f3e72839bd to your computer and use it in GitHub Desktop.
# ~~~ PRE INSTALL ~~~
APP_DIR='/Applications/_4KTestInstaller/'
TEMP_PREFIX='TEMP_'
filesToRestore=('File2.txt' 'Dir2/File2.txt')
echo "** Creazione dei file temporanei **"
echo "-----"
for ((i=0;i<${#filesToRestore[@]};++i)); do
srcFilePath="$APP_DIR${filesToRestore[i]}"
echo "Source File path: $srcFilePath"
srcFileName=$(basename "${srcFilePath}" )
# echo "Source File name: $srcFileName"
srcFileDir=$(dirname "${srcFilePath}")
# echo "Source File dir: $srcFileDir"
destFilePath="$srcFileDir/$TEMP_PREFIX$srcFileName"
echo "Backup File path: $destFilePath"
if [ -e $srcFilePath ] ; then
mv $srcFilePath $destFilePath
fi
echo "-----"
done
# ~~~ POST INSTALL ~~~
APP_DIR='/Applications/_4KTestInstaller/'
APPLICATION_ROOT="${APP_DIR}Chess.app"
TEMP_PREFIX='TEMP_'
filesToRestore=('File2.txt' 'Dir2/File2.txt')
echo "-----"
for ((i=0;i<${#filesToRestore[@]};++i)); do
ORGINAL_FILEPATH="$APP_DIR${filesToRestore[i]}"
echo "Source File path: $ORGINAL_FILEPATH"
srcFileName=$(basename "${ORGINAL_FILEPATH}" )
# echo "Source File name: $srcFileName"
srcFileDir=$(dirname "${ORGINAL_FILEPATH}")
# echo "Source File dir: $srcFileDir"
BACKUP_FILEPATH="$srcFileDir/$TEMP_PREFIX$srcFileName"
echo "Backup File path: $BACKUP_FILEPATH"
if [ -e $BACKUP_FILEPATH ] ; then
mv $BACKUP_FILEPATH $ORGINAL_FILEPATH
fi
echo "-----"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment