-
Notifications
You must be signed in to change notification settings - Fork 872
/
Copy pathaviator
166 lines (144 loc) · 5.37 KB
/
aviator
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
#Aviator script.
#Modified from leiningen:https://raw.github.com/technomancy/leiningen/preview/bin/lein
#License: Eclipse Public License,same as leiningen and clojure.
export AVIATOR_VERSION="5.4.3"
case $AVIATOR_VERSION in
*SNAPSHOT) SNAPSHOT="YES" ;;
*) SNAPSHOT="NO" ;;
esac
if [ `id -u` -eq 0 ] && [ "$AVIATOR_ROOT" = "" ]; then
echo "WARNING: You're currently running as root; probably by accident."
echo "Press control-C to abort or Enter to continue as root."
echo "Set AVIATOR_ROOT to disable this warning."
read _
fi
ORIGINAL_PWD="$PWD"
export AVIATOR_HOME=${AVIATOR_HOME:-"$HOME/.aviatorscript"}
export AVIATOR_DEPS=${AVIATOR_DEPS:-"$AVIATOR_HOME/deps"}
if [ "$OSTYPE" = "cygwin" ]; then
export AVIATOR_HOME=`cygpath -w $AVIATOR_HOME`
fi
AVIATOR_JAR="$AVIATOR_HOME/self-installs/aviator-$AVIATOR_VERSION.jar"
# normalize $0 on certain BSDs
if [ "$(dirname "$0")" = "." ]; then
SCRIPT="$(which $(basename "$0"))"
else
SCRIPT="$0"
fi
# resolve symlinks to the script itself portably
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT="$(dirname "$SCRIPT"$)/$link"
fi
done
BIN_DIR="$(dirname "$SCRIPT")"
# Not running from a checkout
CLASSPATH="$CLASSPATH:$AVIATOR_JAR:$ORIGINAL_PWD"
if [ -d "$AVIATOR_DEPS" ]; then
CLASSPATH="$CLASSPATH:$(ls $AVIATOR_DEPS/*.jar 2> /dev/null | tr '\n' :)"
fi
if [ ! -r "$AVIATOR_JAR" -a "$1" != "self-install" ]; then
"$0" self-install
fi
HTTP_CLIENT=${HTTP_CLIENT:-"wget -O"}
if type -p curl >/dev/null 2>&1; then
if [ "$https_proxy" != "" ]; then
CURL_PROXY="-x $https_proxy"
fi
HTTP_CLIENT="curl $CURL_PROXY -f -L -o"
fi
export JAVA_CMD=${JAVA_CMD:-"java"}
export AVIATOR_JAVA_CMD=${AVIATOR_JAVA_CMD:-$JAVA_CMD}
# Support $JAVA_OPTS for backwards-compatibility.
export JVM_OPTS="${JVM_OPTS:-"$JAVA_OPTS"}"
# TODO: investigate http://skife.org/java/unix/2011/06/20/really_executable_jars.html
# If you're packaging this for a package manager (.deb, homebrew, etc)
# you need to remove the self-install and upgrade functionality or see lein-pkg.
if [ "$1" = "self-install" ]; then
if [ -r "$AVIATOR_JAR" ]; then
echo "The self-install jar already exists at $AVIATOR_JAR."
echo "If you wish to re-download, delete it and rerun \"$0 self-install\"."
exit 1
fi
echo "Downloading AviatorScript now..."
AVIATOR_DIR=`dirname "$AVIATOR_JAR"`
mkdir -p "$AVIATOR_DIR"
mkdir -p "$AVIATOR_DEPS"
AVIATOR_URL="https://github.com/killme2008/aviator/raw/master/downloads/aviator-$AVIATOR_VERSION.jar"
$HTTP_CLIENT "$AVIATOR_JAR" "$AVIATOR_URL"
if [ $? != 0 ]; then
echo "Failed to download $AVIATOR_URL"
echo "If you have an old version of libssl you may not have the correct"
echo "certificate authority. Either upgrade or set HTTP_CLIENT to insecure:"
echo " export HTTP_CLIENT=\"wget --no-check-certificate -O\" # or"
echo " export HTTP_CLIENT=\"curl --insecure -f -L -o"
if [ $SNAPSHOT = "YES" ]; then
echo "If you have Maven installed, you can do"
echo "mvn dependency:copy-dependencies; mv target/dependency lib"
echo "See README.md for further SNAPSHOT build instructions."
fi
rm $AVIATOR_JAR 2> /dev/null
exit 1
fi
elif [ "$1" = "upgrade" ]; then
if [ "$AVIATOR_DIR" != "" ]; then
echo "The upgrade task is not meant to be run from a checkout."
exit 1
fi
if [ $SNAPSHOT = "YES" ]; then
echo "The upgrade task is only meant for stable releases."
echo "See the \"Hacking\" section of the README."
exit 1
fi
if [ ! -w "$SCRIPT" ]; then
echo "You do not have permission to upgrade the installation in $SCRIPT"
exit 1
else
TARGET_VERSION="${2:-"stable"}"
echo "The script at $SCRIPT will be upgraded to the latest $TARGET_VERSION version."
echo -n "Do you want to continue [Y/n]? "
read RESP
case "$RESP" in
y|Y|"")
echo
echo "Upgrading..."
TARGET="/tmp/aviatorcript-$$-upgrade"
if ["$OSTYPE" = "cygwin" ]; then
TARGET=`cygpath -w $TARGET`
fi
AVIATOR_SCRIPT_URL="https://github.com/killme2008/aviator/raw/$TARGET_VERSION/bin/aviator"
$HTTP_CLIENT "$TARGET" "$AVIATOR_SCRIPT_URL" \
&& mv "$TARGET" "$SCRIPT" \
&& chmod +x "$SCRIPT" \
&& echo && "$SCRIPT" self-install && echo && echo "Now running" `$SCRIPT -v`
exit $?;;
*)
echo "Aborted."
exit 1;;
esac
fi
else
if [ "$OSTYPE" = "cygwin" ]; then
# When running on Cygwin, use Windows-style paths for java
ORIGINAL_PWD=`cygpath -w "$ORIGINAL_PWD"`
CLASSPATH=`cygpath -wp "$CLASSPATH"`
fi
if [ $DEBUG ]; then
echo "Classpath: $CLASSPATH"
fi
$AVIATOR_JAVA_CMD \
-client -XX:+TieredCompilation \
$AVIATOR_JVM_OPTS \
-Dfile.encoding=UTF-8 \
-Dmaven.wagon.http.ssl.easy=false \
-Daviatorscript.original.pwd="$ORIGINAL_PWD" \
-cp "$CLASSPATH" \
com.googlecode.aviator.Main "$@"
EXIT_CODE=$?
exit $EXIT_CODE
fi