forked from vincer/gloomhaven-helper-headless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·41 lines (33 loc) · 1.15 KB
/
entrypoint.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
#!/bin/bash
set -euo pipefail
debug="${DEBUG:-}"
if [[ "$debug" ]]; then
set -x
fi
echo "Downloading latest version of Gloomhaven Helper."
version=`curl -s 'https://itunes.apple.com/lookup?bundleId=com.badlogicgames.ghh' | jq -r '.results[0].version'`
curl -O http://esotericsoftware.com/files/ghh/GloomhavenHelper-$version.zip
unzip -o GloomhavenHelper-$version.zip
echo "Setting up config."
if [[ ! -d ~/.ghh ]]; then
echo "No existing config or folder. Setting up basic one."
mkdir ~/.ghh && echo '{server:true,serverPort:58888}' > ~/.ghh/config
elif [[ ! -f ~/.ghh/config ]]; then
echo "No existing config. Setting up basic one."
echo '{server:true,serverPort:58888}' > ~/.ghh/config
else
echo "Existing config. Making sure server is enabled."
sed -i 's/server:false/server:true/' ~/.ghh/config
sed -i 's/client:true/client:false/' ~/.ghh/config
fi
if [[ -z "$@" ]]; then
echo "Starting Gloomhaven Helper"
JAVA_OPTS=""
if [[ "$debug" ]]; then
JAVA_OPTS="${JAVA_OPTS} -verbose"
fi
exec xvfb-run -a java ${JAVA_OPTS} -jar GloomhavenHelper/ghh.jar
else
echo "Running passed command: $@"
exec "$@"
fi