-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch.sh
69 lines (61 loc) · 2.2 KB
/
launch.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
66
67
68
69
#!/bin/bash
ACCOUNT=""
DETACHED_MODE="-d"
DEBUG_MODE=""
RESTART_POLICY="--restart always"
LOG_MOUNT_OPTION=""
for arg in "$@"; do
if [ "$arg" == "-i" ]; then
DETACHED_MODE=""
elif [ "$arg" == "-d" ]; then
DEBUG_MODE="true"
elif [ "$arg" == "-l" ]; then
LOG_MOUNT_OPTION="-v /var/log/partysearchbot:/var/log/partysearchbot"
else
ACCOUNT="$arg"
fi
done
if [ "$DEBUG_MODE" == "true" ]; then
DETACHED_MODE="-d"
RESTART_POLICY="--rm"
fi
if [ -z "$ACCOUNT" ]; then
echo "Please specify an account name."
exit 1
fi
CONTAINER_NAME="partysearchbot_${ACCOUNT}"
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
echo "Container with name $CONTAINER_NAME already exists. Removing it..."
docker rm -f -t 1 $CONTAINER_NAME
fi
# -v "$PWD/accounts":/app/accounts \
docker run $DETACHED_MODE $RESTART_POLICY $LOG_MOUNT_OPTION --name "$CONTAINER_NAME" \
--add-host party.gwtoolbox.com:217.160.162.89 \
-e ACCOUNT="$ACCOUNT" \
partysearchbot_alpine sh -c "
source /app/accounts/\$ACCOUNT.sh &&
NOW=\$(date '+%Y-%m-%d_%H-%M-%S') &&
BIN_DIR=/app/build/bin &&
CLIENT_EXE=\$BIN_DIR/client &&
LOG_FILE=\"/var/log/partysearchbot/\$CHARACTER/\$NOW.txt\" &&
BUILD_VERSION_FILE=\Gw.build &&
PLUGIN_EXE=\$BIN_DIR/libGuildWarsPartySearch.Bot.so &&
LOG_DIR=\$(dirname \"\$LOG_FILE\") &&
mkdir -p \"\$LOG_DIR\" &&
touch \"\$LOG_FILE\" &&
source /app/check_and_update_gw_keys.sh &&
export HEADQUARTER_PASSWORD=\"\$PASSWORD\" &&
export HEADQUARTER_2FA_SECRET=\"\$2FA_SECRET\" &&
RUN_CMD=\"\$CLIENT_EXE -email \\\"\$EMAIL\\\" -character \\\"\$CHARACTER\\\" -district \\\"\$DISTRICT\\\" -travel-mapid \\\"\$MAP_ID\\\" -api-key \\\"\$WEBSOCKET_API_KEY\\\" -websocket-url \\\"\$WEBSOCKET_URL\\\" -l \\\"\$LOG_FILE\\\" -file-game-version \\\"\$BUILD_VERSION_FILE\\\" \$PLUGIN_EXE\" &&
echo \"Running command: \$RUN_CMD\"
if [ \"$DEBUG_MODE\" == \"true\" ]; then
echo \"Container is now in debug mode. Use 'docker exec -ti $CONTAINER_NAME /bin/sh' to access it.\"
exec sleep infinity
else
bash -c \"\$RUN_CMD\"
fi
"
if [ "$DEBUG_MODE" == "true" ]; then
docker exec -ti $CONTAINER_NAME /bin/sh
docker stop -t 1 $CONTAINER_NAME
fi