-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.sh
executable file
·121 lines (106 loc) · 4.24 KB
/
setup.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# ---------------------------------------------------------------------------
# Setup processing for
#
# Environment Variable Prequisites
#
# JAVA_HOME Directory of Java Version
#
#
# $Id: setup.sh,v 1.1 2008/11/13 16:23:07 mohanar Exp $
# ---------------------------------------------------------------------------
getValuesFromCommandLine() {
ADMIN_EMAIL=$1; shift;
SMTP_SERVER=$1; shift;
XNAT_URL=$1; shift;
# Set default values for these variables.
XNAT_SITE_NAME=XNAT
DESTINATION=""
MODULE_PATHS=""
if [ ! -z $1 ]; then
XNAT_SITE_NAME=$1; shift
if [ ! -z $1 ]; then
DESTINATION=$1; shift;
if [ ! -z $1 ]; then
MODULE_PATHS=$(echo $@ | sed 's/[ ,]\{1,\}/,/g')
fi
fi
fi
}
echo
#======================================================================================================
# WORK_DIR gotten from http://software-lgl.blogspot.com/2009/03/find-full-path-of-your-bash-script.html
#======================================================================================================
WORK_DIR=`dirname "$(cd ${0%/*} && echo $PWD/${0##*/})"`
if [ -z $WORK_DIR ]; then
WORK_DIR=`pwd`
fi
cd $WORK_DIR
[ -e gradle.properties ]
HAS_GRADLE_PROPS=$?
ARG_COUNT=$#
if (( ARG_COUNT < 3 && HAS_GRADLE_PROPS != 0 )); then
echo "Missing required command line arguments"
echo "USAGE: $0 <admin email> <SMTP server> <XNAT url> [XNAT site name] [destination] [modulePath1 modulePath2 modulePath3... modulePathn]"
exit 1
fi
echo " "
echo "Using JAVA_HOME: $JAVA_HOME"
echo " "
echo "Verify Java Version (with java -version)"
java -version
if (( ARG_COUNT > 2 )); then
getValuesFromCommandLine $@
if (( HAS_GRADLE_PROPS == 0 )); then
echo ""
echo There is a gradle.properties file in your installer folder. Would you like to save the values from this command
echo into gradle.properties? The existing file will be backed up in the current folder if so.
echo ""
else
echo ""
echo Would you like to save your pipeline configuration settings to the gradle.properties file in your installer
echo folder. This will allow you to re-run the pipeline installation in the future without having to provide all
echo of the configuration values again.
echo ""
fi
SELECT=1
while ! [[ ${SELECT} =~ [YyNn] ]]; do
read -n1 -p "Y/n: " SELECT
if ! [[ ${SELECT} =~ [YyNn] ]]; then
echo ""
echo Please press either Y or N.
fi
done
echo ""
if [[ ${SELECT} =~ [Yy] ]]; then
if (( HAS_GRADLE_PROPS == 0 )); then
mv gradle.properties gradle.properties.bak-$(date +%Y%m%d%H%M%S)
echo Moved existing gradle.properties to !$.
fi
echo \# gradle.properties generated by setup.sh script at $(date) > gradle.properties
echo \# Original command line: >> gradle.properties
echo \# $* >> gradle.properties
echo adminEmail=${ADMIN_EMAIL} >> gradle.properties
echo smtpServer=${SMTP_SERVER} >> gradle.properties
echo xnatUrl=${XNAT_URL} >> gradle.properties
echo siteName=${XNAT_SITE_NAME} >> gradle.properties
[[ -n ${DESTINATION} ]] && { echo destination=${DESTINATION} >> gradle.properties; }
[[ -n ${MODULE_PATHS} ]] && { echo modulePaths=${MODULE_PATHS} >> gradle.properties; }
USE_GRADLE_PROPS=0
else
USE_GRADLE_PROPS=1
fi
else
USE_GRADLE_PROPS=0
fi
chmod +x $WORK_DIR/gradlew
if (( USE_GRADLE_PROPS == 0 )); then
echo Executing $WORK_DIR/gradlew with settings from gradle.properties.
./gradlew
else
[[ -n ${DESTINATION} ]] && { DESTINATION_OPT=-Pdestination=${DESTINATION}; echo Set DESTINATION_OPT to ${DESTINATION_OPT}; }
[[ -n ${MODULE_PATHS} ]] && { MODULE_PATHS_OPT=-PmodulePaths=${MODULE_PATHS}; echo Set MODULE_PATHS_OPT to ${MODULE_PATHS_OPT}; }
echo Executing $WORK_DIR/gradlew -PadminEmail="$ADMIN_EMAIL" -PsmtpServer="$SMTP_SERVER" -PxnatUrl="$XNAT_URL" -PsiteName="$XNAT_SITE_NAME" $DESTINATION_OPT $MODULE_PATHS_OPT
./gradlew -PadminEmail="$ADMIN_EMAIL" -PsmtpServer="$SMTP_SERVER" -PxnatUrl="$XNAT_URL" -PsiteName="$XNAT_SITE_NAME" $DESTINATION_OPT $MODULE_PATHS_OPT
fi
exit $?