-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle.sh
executable file
·62 lines (49 loc) · 1.91 KB
/
gradle.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
#!/bin/bash -ex
#include common functions
MY_PATH=`dirname $(readlink -f "$0")`
source "${MY_PATH}/_utils.sh"
function usage {
echo "Usage:"
echo " $0 -r <packageUrl> -t <releaseDir> [-u <downloadUsername>] [-p <downloadPassword>] [-a <awsCliProfile>]"
echo " -r Package url (http, S3 or local file)"
echo " -t Target release dir normaly a folder where the last path is 'releases' "
echo " -u Download username"
echo " -p Download password"
echo " -a aws cli profile (defaults to 'default')"
echo ""
echo "Optional you can set following Variables: YAD_INSTALL_SCRIPT"
exit $1
}
if [ -z "${YAD_INSTALL_SCRIPT}" ]; then
echo "Use default YAD_INSTALL_SCRIPT"
YAD_INSTALL_SCRIPT="./gradlew"
fi
AWSCLIPROFILE='default'
EXTRA=0
while getopts 'r:t:u:p:a:' OPTION ; do
case "${OPTION}" in
r) YAD_PACKAGE="${OPTARG}";;
t) YAD_RELEASE_FOLDER="${OPTARG}";;
u) YAD_PACKAGE_USERNAME="${OPTARG}";;
p) YAD_PACKAGE_PASSWORD="${OPTARG}";;
s) YAD_SHARED_FOLDER_BASE="${OPTARG}";;
a) AWSCLIPROFILE="${OPTARG}";;
\?) echo; usage 1;;
esac
done
# Create tmp dir and make sure it's going to be deleted in any case
TMPDIR=`mktemp -d`
function cleanup {
echo "Removing temp dir ${TMPDIR}"
rm -rf "${TMPDIR}"
}
trap cleanup EXIT
PACKAGE_BASENAME=`basename $YAD_PACKAGE`
download $YAD_PACKAGE $TMPDIR $PACKAGE_BASENAME
echo "Extracting setup package"
unzip -o "${TMPDIR}/${PACKAGE_BASENAME}" "setup/*" -d "${TMPDIR}" || { echo "Error while extracting setup package" ; exit 1; }
cd "${TMPDIR}/setup/"
source /etc/profile.d/GRADLE_HOME.sh
# Install the package
command -v ${YAD_INSTALL_SCRIPT} > /dev/null 2>&1 || { echo >&2 "${YAD_INSTALL_SCRIPT} not available - you may want to define another installer with the Variable YAD_INSTALL_SCRIPT. Aborting."; exit 1; }
${YAD_INSTALL_SCRIPT} || { echo "Installing package failed"; exit 1; }