2017-11-27 20:15:49 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
################################################################################
|
2018-01-22 18:21:09 +08:00
|
|
|
# Updates CARLA content.
|
2017-11-27 20:15:49 +08:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-01-22 18:21:09 +08:00
|
|
|
DOC_STRING="Update CARLA content to the latest version, to be run after 'git pull'."
|
|
|
|
|
|
|
|
USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download]"
|
|
|
|
|
2018-01-16 00:03:33 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Parse arguments -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
SKIP_DOWNLOAD=false
|
|
|
|
|
|
|
|
OPTS=`getopt -o hs --long help,skip-download -n 'parse-options' -- "$@"`
|
|
|
|
|
|
|
|
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
|
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-s | --skip-download )
|
|
|
|
SKIP_DOWNLOAD=true;
|
|
|
|
shift ;;
|
|
|
|
-h | --help )
|
2018-01-22 18:21:09 +08:00
|
|
|
echo "$DOC_STRING"
|
2018-01-16 00:03:33 +08:00
|
|
|
echo "$USAGE_STRING"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Set up environment --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2017-11-27 20:15:49 +08:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
pushd "$SCRIPT_DIR" >/dev/null
|
|
|
|
|
2018-07-19 22:15:34 +08:00
|
|
|
CONTENT_FOLDER=$SCRIPT_DIR/Unreal/CarlaUE4/Content/Carla
|
2017-11-27 20:15:49 +08:00
|
|
|
|
2019-03-18 23:21:07 +08:00
|
|
|
CONTENT_ID=$(tac $SCRIPT_DIR/Util/ContentVersions.txt | egrep -m 1 . | rev | cut -d' ' -f1 | rev)
|
|
|
|
CONTENT_LINK=http://carla-assets-internal.s3.amazonaws.com/Content/${CONTENT_ID}.tar.gz
|
2017-11-27 20:15:49 +08:00
|
|
|
|
|
|
|
VERSION_FILE=${CONTENT_FOLDER}/.version
|
|
|
|
|
|
|
|
function download_content {
|
|
|
|
if [[ -d "$CONTENT_FOLDER" ]]; then
|
|
|
|
echo "Backing up existing Content..."
|
|
|
|
mv -v "$CONTENT_FOLDER" "${CONTENT_FOLDER}_$(date +%Y%m%d%H%M%S)"
|
|
|
|
fi
|
|
|
|
mkdir -p $CONTENT_FOLDER
|
|
|
|
mkdir -p Content
|
2019-03-19 21:36:14 +08:00
|
|
|
if hash aria2c 2>/dev/null; then
|
|
|
|
echo -e "${CONTENT_LINK}\n\tout=Content.tar.gz" > .aria2c.input
|
2019-03-19 22:27:04 +08:00
|
|
|
aria2c -j16 -x16 --input-file=.aria2c.input
|
2019-03-19 21:36:14 +08:00
|
|
|
rm -f .aria2c.input
|
|
|
|
else
|
2019-04-23 18:11:56 +08:00
|
|
|
wget -c ${CONTENT_LINK} -O Content.tar.gz
|
2019-03-19 21:36:14 +08:00
|
|
|
fi
|
2017-11-27 20:15:49 +08:00
|
|
|
tar -xvzf Content.tar.gz -C Content
|
|
|
|
rm Content.tar.gz
|
|
|
|
mv Content/* $CONTENT_FOLDER
|
2019-03-20 19:34:21 +08:00
|
|
|
rm -rf Content
|
2019-03-18 23:21:07 +08:00
|
|
|
echo "$CONTENT_ID" > "$VERSION_FILE"
|
2017-11-27 20:15:49 +08:00
|
|
|
echo "Content updated successfully."
|
|
|
|
}
|
|
|
|
|
2018-01-16 00:03:33 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Download Content if necessary ---------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if $SKIP_DOWNLOAD ; then
|
|
|
|
echo "Skipping 'Content' update. Please manually download the package from"
|
|
|
|
echo
|
2019-03-18 23:21:07 +08:00
|
|
|
echo " ${CONTENT_LINK}"
|
2018-01-16 00:03:33 +08:00
|
|
|
echo
|
2018-07-19 22:15:34 +08:00
|
|
|
echo "and extract it under Unreal/CarlaUE4/Content/Carla."
|
2018-01-16 00:03:33 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-11-27 20:15:49 +08:00
|
|
|
if [[ -d "$CONTENT_FOLDER/.git" ]]; then
|
|
|
|
echo "Using git version of 'Content', skipping update."
|
|
|
|
elif [[ -f "$CONTENT_FOLDER/.version" ]]; then
|
2019-03-18 23:21:07 +08:00
|
|
|
if [ "$CONTENT_ID" == `cat $VERSION_FILE` ]; then
|
2017-11-27 20:15:49 +08:00
|
|
|
echo "Content is up-to-date."
|
|
|
|
else
|
|
|
|
download_content
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
download_content
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd >/dev/null
|