-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.sh
executable file
·57 lines (48 loc) · 1.14 KB
/
main.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
#!/bin/bash
# Function to display script usage
display_usage() {
echo "Usage: $0 [--supergraphPath <supergraphPath>] [--port <port>]"
}
# Check if Ballerina is installed
if ! command -v bal &>/dev/null; then
echo "Error: Ballerina is not installed."
exit 1
fi
jar_file="./ballerina/target/bin/graphql_federation_gateway.jar"
jar_url="https://github.com/xlibb/graphql-federation-gateway/releases/download/v0.1.0/graphql_federation_gateway.jar"
if [[ ! -f $jar_file ]]; then
wget -O $jar_file $jar_url
fi
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-s|--supergraphPath)
supergraphPath=$2
shift 2
;;
-p|--port)
port=$2
shift 2
;;
*)
echo "Invalid option: $1"
display_usage
exit 1
;;
esac
done
# Set default values if arguments are not provided
outputPath = $(mktemp -d)
port = ${port:-9090}
# Execute the jar with the provided input values
result=$(
bal run "${jar_file}" \
-CsupergraphPath="${supergraphPath}" \
-CoutputPath="${outputPath}" \
-Cport="${port}"
)
if [ -n "$result" ]; then
echo $result
exit 1
fi
bal run $outputPath