forked from eclipse-jifa/jifa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jifa.sh
65 lines (57 loc) · 1.39 KB
/
jifa.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
#!/bin/sh
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
set -eu
TAG="latest"
PORT="8102"
MOUNTS=""
INPUT_FILES=""
INPUT_FILE_COUNT=0
JVM_OPTIONS=""
check_docker() {
if ! command -v docker &>/dev/null; then
echo "docker is not installed"
exit 1
fi
}
launch_jifa() {
check_docker
docker run --pull=always -e JAVA_TOOL_OPTIONS="$JVM_OPTIONS" -p ${PORT}:${PORT} $MOUNTS eclipsejifa/jifa:${TAG} --jifa.port=${PORT} $INPUT_FILES
}
while [ $# -gt 0 ]; do
case $1 in
-t)
TAG=$2
shift
;;
-p)
PORT=$2
shift
;;
--jvm-options)
JVM_OPTIONS=$2
shift
;;
*)
ABSOLUTE_PATH=$(realpath "$1")
if [ ! -f "$ABSOLUTE_PATH" ]; then
echo "$1 does not exist or is not a regular file"
exit 1
fi
FILE_NAME=$(basename "$ABSOLUTE_PATH")
MOUNTS="$MOUNTS -v $ABSOLUTE_PATH:/input-file-$INPUT_FILE_COUNT/$FILE_NAME"
INPUT_FILES="$INPUT_FILES --jifa.input-files[$INPUT_FILE_COUNT]=/input-file-$INPUT_FILE_COUNT/$FILE_NAME"
INPUT_FILE_COUNT=$((INPUT_FILE_COUNT+1))
;;
esac
shift
done
launch_jifa