forked from filodb/FiloDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filo-cli
executable file
·47 lines (38 loc) · 1.01 KB
/
filo-cli
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
#!/usr/bin/env bash
# set -x
SCALA_VERSION="2.12"
FILO_VERSION=$(cat version.sbt | sed -e 's/.*"\(.*\)"/\1/g')
CLI_FILE=`pwd`"/cli/target/scala-$SCALA_VERSION/filo-cli-$FILO_VERSION"
function isJava8(){
if [[ "$JAVA" ]]; then
version=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ "$version" < "1.8" ]]; then
echo "FiloDB requires Java JDK 1.8 and the current version is $version. Please upgrade to continue."
exit
fi
fi
}
function check_java {
JAVA=$(type -p java)
if [ -z "$JAVA" ]; then
echo "Failed to find Java in PATH. Please install Java JDK 1.8"
exit
fi
}
function check_sbt {
if [ -z $1 ]; then
echo "Failed to find SBT in PATH. Please install SBT"
exit
fi
}
isJava8
check_java
SBT=$(type -p sbt)
check_sbt $SBT
if [ ! -f "$CLI_FILE" ];then
# run assembly if file doesn't exist
$SBT cli/assembly
# initialize DB on first run
$CLI_FILE --command init
fi
$CLI_FILE "$@"