-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
entrypoint-user.sh
executable file
·124 lines (110 loc) · 3.21 KB
/
entrypoint-user.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
exit_handler_user() {
# Execute the shutdown commands
echo -e "Stopping ${GAMESERVER}"
./"${GAMESERVER}" stop
exitcode=$?
exit ${exitcode}
}
# Exit trap
echo -e "Loading exit handler"
trap exit_handler_user SIGQUIT SIGINT SIGTERM
# Setup game server
if [ ! -f "${GAMESERVER}" ]; then
echo -e ""
echo -e "creating ${GAMESERVER}"
echo -e "================================="
./linuxgsm.sh "${GAMESERVER}"
fi
# Symlink LGSM_CONFIG to /app/lgsm/config-lgsm
if [ ! -d "/app/lgsm/config-lgsm" ]; then
echo -e ""
echo -e "creating symlink for ${LGSM_CONFIG}"
echo -e "================================="
ln -s "${LGSM_CONFIG}" "/app/lgsm/config-lgsm"
fi
# Symlink LGSM_SERVERCFG to /app/serverfiles
if [ ! -d "/app/serverfiles" ]; then
echo -e ""
echo -e "creating symlink for ${LGSM_SERVERCFG}"
echo -e "================================="
ln -s "${LGSM_SERVERFILES}" "/app/serverfiles"
fi
# Symlink LGSM_LOGDIR to /app/log
if [ ! -d "/app/log" ]; then
echo -e ""
echo -e "creating symlink for ${LGSM_LOGDIR}"
echo -e "================================="
ln -s "${LGSM_LOGDIR}" "/app/log"
fi
# Symlink LGSM_DATADIR to /app/lgsm/data
if [ ! -d "/app/lgsm/data" ]; then
echo -e ""
echo -e "creating symlink for ${LGSM_DATADIR}"
echo -e "================================="
ln -s "${LGSM_DATADIR}" "/app/lgsm/data"
fi
# npm install in /app/lgsm
if [ -f "/app/lgsm/package.json" ]; then
echo -e ""
echo -e "npm install in /app/lgsm"
echo -e "================================="
cd /app/lgsm || exit
npm install
cd /app || exit
fi
# Clear modules directory if not master
if [ "${LGSM_GITHUBBRANCH}" != "master" ]; then
echo -e "not master branch, clearing modules directory"
rm -rf /app/lgsm/modules/*
./"${GAMESERVER}" update-lgsm
elif [ -d "/app/lgsm/modules" ]; then
echo -e "ensure all modules are executable"
chmod +x /app/lgsm/modules/*
fi
# Enable developer mode
if [ "${LGSM_DEV}" == "true" ]; then
echo -e "developer mode enabled"
./"${GAMESERVER}" developer
fi
# Install game server
if [ -z "$(ls -A -- "/data/serverfiles" 2> /dev/null)" ]; then
echo -e ""
echo -e "Installing ${GAMESERVER}"
echo -e "================================="
./"${GAMESERVER}" auto-install
install=1
else
echo -e ""
# Sponsor to display LinuxGSM logo
./"${GAMESERVER}" sponsor
fi
echo -e ""
echo -e "Starting Update Checks"
echo -e "================================="
echo -e "*/${UPDATE_CHECK} * * * * /app/${GAMESERVER} update > /dev/null 2>&1" | crontab -
echo -e "update will check every ${UPDATE_CHECK} minutes"
# Update or validate game server
if [ -z "${install}" ]; then
echo -e ""
if [ "${VALIDATE_ON_START,,}" = "true" ]; then
echo -e "Validating ${GAMESERVER}"
echo -e "================================="
./"${GAMESERVER}" validate
else
echo -e "Checking for Update ${GAMESERVER}"
echo -e "================================="
./"${GAMESERVER}" update
fi
fi
echo -e ""
echo -e "Starting ${GAMESERVER}"
echo -e "================================="
./"${GAMESERVER}" start
sleep 5
./"${GAMESERVER}" details
sleep 2
echo -e "Tail log files"
echo -e "================================="
tail -F "${LGSM_LOGDIR}"/{console,script}/*{console,script}.log &
wait