-
-
Save cmsj/a4d225722c2cd92e8982 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Put this script in the folder that your Games_WHDLoad directory lives in. Dump update pack directories in the same place and run the script | |
| export SETOPTS="${SETOPTS:--eux}" | |
| set "${SETOPTS}" | |
| export BASEDIR | |
| BASEDIR="$(dirname "$0")" | |
| export GAMESDIR="${BASEDIR}/Games_WHDLoad" | |
| apply_update() { | |
| set "${SETOPTS}" | |
| UPDATEDIR="$(dirname "$1")" | |
| LETTERDIR="$(basename "${UPDATEDIR}")" | |
| GAME="$(basename "$1")" | |
| OLDGAME="${GAMESDIR}/${LETTERDIR}/${GAME}" | |
| echo " ${GAME}:" | |
| if [ -d "${OLDGAME}" ]; then | |
| echo " Removing previous version" | |
| rm -rf "${OLDGAME}" | |
| rm "${OLDGAME}.info" | |
| fi | |
| echo -n " Copying..." | |
| rsync -qarx "${UPDATEDIR}/${GAME}" "${GAMESDIR}/${LETTERDIR}/" | |
| rsync -qarx "${UPDATEDIR}/${GAME}.info" "${GAMESDIR}/${LETTERDIR}/" | |
| echo "Done." | |
| echo -n " Removing from update pack..." | |
| rm -rf "${UPDATEDIR:?}/${GAME}" | |
| rm "${UPDATEDIR}/${GAME}.info" | |
| echo "Done." | |
| } | |
| update_from_dir() { | |
| set "${SETOPTS}" | |
| UPDATEDIR="$1" | |
| echo " Applying updates from ${UPDATEDIR}:" | |
| echo "" | |
| find "${UPDATEDIR}" -depth 1 -maxdepth 1 -type d -exec bash -c 'apply_update "$0"' {} \; | |
| rm -r "${UPDATEDIR}" | |
| echo "" | |
| } | |
| traverse_update_pack() { | |
| set "${SETOPTS}" | |
| PACK="$1" | |
| PACK_NAME="$(basename "${PACK}")" | |
| PACK_VERSION="${PACK_NAME:7:3}" | |
| echo "Examining update pack ${PACK_VERSION} for updates..." | |
| echo "" | |
| find "${PACK}" -depth 1 -maxdepth 1 -type d -name '?' -exec bash -c 'update_from_dir "$0"' {} \; | |
| rm -r "${PACK}" | |
| echo "" | |
| echo "${PACK_VERSION}" >>processed_updates.txt | |
| } | |
| export -f apply_update | |
| export -f update_from_dir | |
| export -f traverse_update_pack | |
| find "${BASEDIR}" -maxdepth 1 -type d -name 'Update_*Games_WHDLoad' -exec bash -c 'traverse_update_pack "$0"' {} \; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment