This repository was archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathentrypoint.sh
81 lines (67 loc) · 1.91 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
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
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
exit_handler () {
# Execute the shutdown commands
echo "recieved SIGTERM stopping ${GAMESERVER}"
./${GAMESERVER} stop
exit 0
}
# Exit trap
echo "loading exit trap"
trap exit_handler SIGTERM
echo -e "Welcome to the LinuxGSM Docker"
echo -e "================================================================================"
echo -e "GAMESERVER: ${GAMESERVER}"
echo -e "UID: $UID"
echo -e ""
echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}"
echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}"
echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}"
echo -e ""
echo -e "Initalising"
echo -e "================================================================================"
# Correct permissions in home dir
echo "update permissions for linuxgsm"
sudo chown -R linuxgsm:linuxgsm /home/linuxgsm
# Copy linuxgsm.sh into homedir
if [ ! -e ~/linuxgsm.sh ]; then
echo "copying linuxgsm.sh to /home/linuxgsm"
cp /linuxgsm.sh ~/linuxgsm.sh
fi
# Setup game server
if [ ! -f "${GAMESERVER}" ]; then
echo "creating ./${GAMESERVER}"
./linuxgsm.sh ${GAMESERVER}
fi
# Install game server
if [ -z "$(ls -A -- "serverfiles")" ]; then
echo "installing ${GAMESERVER}"
./${GAMESERVER} auto-install
fi
echo "starting cron"
sudo cron
# Update game server
echo ""
echo "update ${GAMESERVER}"
./${GAMESERVER} update
echo ""
echo "start ${GAMESERVER}"
./${GAMESERVER} start
sleep 5
./${GAMESERVER} details
tail -f log/script/*
# with no command, just spawn a running container suitable for exec's
if [ $# = 0 ]; then
tail -f /dev/null
else
# execute the command passed through docker
"$@"
# if this command was a server start cmd
# to get around LinuxGSM running everything in
# tmux;
# we attempt to attach to tmux to track the server
# this keeps the container running
# when invoked via docker run
# but requires -it or at least -t
tmux set -g status off && tmux attach 2> /dev/null
fi
exec "$@"