forked from MightyDetail/docker-fivem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
69 lines (57 loc) · 2.23 KB
/
entrypoint
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/sh
# Checking environments and setting defaults ----- Start ----- >
if [ -z "${HOST_UID}" ]; then
echo "Host user ID not found in environment. Using root (0)."
export HOST_UID=0
fi
if [ -z "${HOST_GID}" ]; then
echo "Host group ID not found in environment. Using root (0)."
export HOST_GID=0
fi
if [ -z "${FIVEM_PORT}" ]; then
echo "FiveM port not found in environment. Using default 30120"
export FIVEM_PORT=30120
fi
if [ -z "${TXADMIN_PORT}" ]; then
echo "txAdmin port not found in environment."
export TXADMIN_PORT=40120
fi
if [ -z "${SERVER_PROFILE}" ]; then
echo "txAdmin profile not found in environment. Using dev_server"
export SERVER_PROFILE="dev_server"
fi
# Checking environments and setting defaults ----- End ----- <
# Making fivem user and group to run the server -------------------
if ! getent group "${HOST_GID}" | cut -d: -f1 | read; then
addgroup fivem -g "${HOST_GID}"
HOST_GROUPNAME="fivem"
else
HOST_GROUPNAME=`getent group "${HOST_GID}" | cut -d: -f1`
fi
if ! getent passwd "${HOST_UID}" | cut -d: -f1 | read; then
adduser fivem -D -G "$HOST_GROUPNAME" --uid "$HOST_UID"
HOST_USERNAME="fivem"
else
HOST_USERNAME=`getent passwd "${HOST_UID}" | cut -d: -f1`
fi
# -----------------------------------------------------------------
# Copying and customizing server files -----------------------------------------
if ! find . -mindepth 1 | read; then
echo -e "Creating default configs...\n"
cp -r /opt/cfx-server-data/* /config
fi
# -------------------------------------------------------------------------------
# Setting permissions on config folder. (Contains resources folder)
chown "$HOST_USERNAME":"$HOST_GROUPNAME" -R /config
# ------------------------------------------------------------------
# Making and setting permissions on txData folder ------
mkdir -p /txData
chown ${HOST_USERNAME}:${HOST_GROUPNAME} -R /txData
# -------------------------------------------------------
# Starting fiveM servrer --------------------------------
exec su "$HOST_USERNAME" -c "/opt/cfx-server/FXServer \
+set citizen_dir /opt/cfx-server/citizen/ \
+set serverProfile ${SERVER_PROFILE} \
+set txAdminPort ${TXADMIN_PORT} \
$@"
# -------------------------------------------------------