forked from spritsail/fivem
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint
More file actions
79 lines (64 loc) · 2.33 KB
/
entrypoint
File metadata and controls
79 lines (64 loc) · 2.33 KB
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
#!/bin/sh
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 "${LICENCE_KEY}" ]; then
echo "Licence key not found in environment, please create one at https://keymaster.fivem.net!"
export LICENCE_KEY=
fi
if [ -z "${FIVEM_PORT}" ]; then
echo "FiveM port not found in environment. Using default 30120"
export FIVEM_PORT=30120
fi
if [ -z "${WEB_PORT}" ]; then
echo "Web port not found in environment."
export WEB_PORT=40120
fi
if [ -z "${SERVER_PROFILE}" ]; then
echo "txAdmin profile not found in environment. Using dev_server"
export SERVER_PROFILE="dev_server"
fi
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
if ! find . -mindepth 1 | read; then
echo -e "Creating default configs...\n"
cp -r /opt/cfx-server-data/* /config
RCON_PASS="${RCON_PASSWORD-$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 16)}"
sed -i "s/{RCON_PASS}/${RCON_PASS}/g" /config/server.cfg;
sed -i "s/{FIVEM_PORT}/${FIVEM_PORT}/g" /config/server.cfg;
echo "----------------------------------------------"
echo "Your RCON password is set to: ${RCON_PASS}"
echo -e "----------------------------------------------\n"
sed -i "s/{LICENCE_KEY}/${LICENCE_KEY}/g" /config/server.cfg;
fi
chown "$HOST_USERNAME":"$HOST_GROUPNAME" -R /config
# find /config -type d -exec chmod 770 {} +
# find /config -type f -exec chmod 660 {} +
if [ -z "${LICENCE_KEY}" ]; then
echo "Licence key not found in environment, please create one at https://keymaster.fivem.net!"
exit 1
fi
mkdir -p /txData
chown ${HOST_USERNAME}:${HOST_GROUPNAME} -R /txData
# find /txData -type d -exec chmod 770 {} +
# find /txData -type f -exec chmod 660 {} +
exec su "$HOST_USERNAME" -c "/opt/cfx-server/FXServer \
+set citizen_dir /opt/cfx-server/citizen/ \
+set serverProfile ${SERVER_PROFILE} \
+set txAdminPort ${WEB_PORT} \
$@"