forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update.sh
executable file
·101 lines (81 loc) · 2.97 KB
/
Update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/bash
################################################################################
# Updates CARLA content.
################################################################################
set -e
DOC_STRING="Update CARLA content to the latest version, to be run after 'git pull'."
USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download]"
# ==============================================================================
# -- 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 )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
# ==============================================================================
# -- Set up environment --------------------------------------------------------
# ==============================================================================
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null
CONTENT_FOLDER=$SCRIPT_DIR/Unreal/CarlaUE4/Content/Carla
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
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
if hash aria2c 2>/dev/null; then
echo -e "${CONTENT_LINK}\n\tout=Content.tar.gz" > .aria2c.input
aria2c -j16 -x16 --input-file=.aria2c.input
rm -f .aria2c.input
else
wget -c ${CONTENT_LINK} -O Content.tar.gz
fi
tar -xvzf Content.tar.gz -C Content
rm Content.tar.gz
mv Content/* $CONTENT_FOLDER
rm -rf Content
echo "$CONTENT_ID" > "$VERSION_FILE"
echo "Content updated successfully."
}
# ==============================================================================
# -- Download Content if necessary ---------------------------------------------
# ==============================================================================
if $SKIP_DOWNLOAD ; then
echo "Skipping 'Content' update. Please manually download the package from"
echo
echo " ${CONTENT_LINK}"
echo
echo "and extract it under Unreal/CarlaUE4/Content/Carla."
exit 0
fi
if [[ -d "$CONTENT_FOLDER/.git" ]]; then
echo "Using git version of 'Content', skipping update."
elif [[ -f "$CONTENT_FOLDER/.version" ]]; then
if [ "$CONTENT_ID" == `cat $VERSION_FILE` ]; then
echo "Content is up-to-date."
else
download_content
fi
else
download_content
fi
popd >/dev/null