4
0
Эх сурвалжийг харах

feat(fivemserver): add FiveM server

Adds FiveM (GTA V multiplayer, Cfx.re FXServer) as fivemserver.

- update_fivem.sh installs and updates the "recommended" Linux build from
  the Cfx.re changelog API, and tracks the installed build in a data file
  for check-update and update.
- Install fetches the base resources from citizenfx/cfx-server-data (a
  tarball of the default branch) once. Updates never touch resources.
- FXServer always starts with +exec server.cfg, so the bundled txAdmin web
  panel never starts and LinuxGSM is the only thing managing the server.
- licensekey in the LinuxGSM config is passed as +set sv_licenseKey.
  start and debug stop with a clear message if no key is set here or in
  server.cfg.
- Details parse server.cfg, and querying uses gamedig (gta5f).
Daniel Gibbs 20 цаг өмнө
parent
commit
e6087ce693
38 өөрчлөгдсөн 458 нэмэгдсэн , 3 устгасан
  1. 199 0
      lgsm/config-default/config-lgsm/fivemserver/_default.cfg
  2. 1 0
      lgsm/data/almalinux-8.csv
  3. 1 0
      lgsm/data/almalinux-9.csv
  4. 1 0
      lgsm/data/centos-7.csv
  5. 1 0
      lgsm/data/centos-8.csv
  6. 1 0
      lgsm/data/centos-9.csv
  7. 1 0
      lgsm/data/debian-10.csv
  8. 1 0
      lgsm/data/debian-11.csv
  9. 1 0
      lgsm/data/debian-12.csv
  10. 1 0
      lgsm/data/debian-13.csv
  11. 1 0
      lgsm/data/debian-9.csv
  12. BIN
      lgsm/data/gameicons/fivem-icon.png
  13. 1 0
      lgsm/data/rhel-7.csv
  14. 1 0
      lgsm/data/rhel-8.csv
  15. 1 0
      lgsm/data/rhel-9.csv
  16. 1 0
      lgsm/data/rocky-8.csv
  17. 1 0
      lgsm/data/rocky-9.csv
  18. 1 0
      lgsm/data/serverlist.csv
  19. 1 0
      lgsm/data/ubuntu-16.04.csv
  20. 1 0
      lgsm/data/ubuntu-18.04.csv
  21. 1 0
      lgsm/data/ubuntu-20.04.csv
  22. 1 0
      lgsm/data/ubuntu-22.04.csv
  23. 1 0
      lgsm/data/ubuntu-23.04.csv
  24. 1 0
      lgsm/data/ubuntu-23.10.csv
  25. 1 0
      lgsm/data/ubuntu-24.04.csv
  26. 1 0
      lgsm/data/ubuntu-26.04.csv
  27. 10 0
      lgsm/modules/check_config.sh
  28. 2 0
      lgsm/modules/command_check_update.sh
  29. 2 0
      lgsm/modules/command_install.sh
  30. 2 0
      lgsm/modules/command_update.sh
  31. 2 2
      lgsm/modules/core_getopt.sh
  32. 10 0
      lgsm/modules/core_modules.sh
  33. 20 0
      lgsm/modules/info_game.sh
  34. 17 1
      lgsm/modules/info_messages.sh
  35. 5 0
      lgsm/modules/install_config.sh
  36. 24 0
      lgsm/modules/install_fivem_license.sh
  37. 2 0
      lgsm/modules/install_server_files.sh
  38. 139 0
      lgsm/modules/update_fivem.sh

+ 199 - 0
lgsm/config-default/config-lgsm/fivemserver/_default.cfg

@@ -0,0 +1,199 @@
+##################################
+######## Default Settings ########
+##################################
+# DO NOT EDIT, ANY CHANGES WILL BE OVERWRITTEN!
+# Copy settings from here and use them in either:
+# common.cfg - applies settings to every instance.
+# [instance].cfg - applies settings to a specific instance.
+
+#### Game Server Settings ####
+
+## Cfx.re License Key (Required) | https://portal.cfx.re/servers/registration-keys
+# Every FiveM server needs its own free license key from the Cfx.re portal.
+licensekey=""
+
+## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
+## Game Server Docs | https://docs.fivem.net/docs/server-manual/setting-up-a-server-vanilla/
+# Ports, server name and max players are set in server.cfg.
+startparameters="+exec ${servercfg} +set sv_licenseKey ${licensekey}"
+
+#### LinuxGSM Settings ####
+
+## LinuxGSM Stats
+# Send useful stats to LinuxGSM developers.
+# https://docs.linuxgsm.com/configuration/linuxgsm-stats
+# (on|off)
+stats="off"
+
+## Notification Alerts
+# (on|off)
+
+# Display IP | https://docs.linuxgsm.com/alerts#display-ip
+displayip=""
+
+# More info | https://docs.linuxgsm.com/alerts#more-info
+postalert="off"
+
+# Alert on Start/Stop/Restart
+statusalert="off"
+
+# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
+discordalert="off"
+discordwebhook="webhook"
+
+# Email Alerts | https://docs.linuxgsm.com/alerts/email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# Gotify Alerts | https://docs.linuxgsm.com/alerts/gotify
+gotifyalert="off"
+gotifytoken="token"
+gotifywebhook="webhook"
+
+# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt
+iftttalert="off"
+ifttttoken="accesstoken"
+iftttevent="linuxgsm_alert"
+
+# ntfy Alerts | https://docs.linuxgsm.com/alerts/ntfy
+ntfyalert="off"
+ntfytopic="LinuxGSM"
+ntfyserver="https://ntfy.sh"
+ntfytoken=""
+ntfyusername=""
+ntfypassword=""
+ntfypriority=""
+ntfytags=""
+
+# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover
+pushoveralert="off"
+pushovertoken="accesstoken"
+pushoveruserkey="userkey"
+
+# Rocket.Chat Alerts | https://docs.linuxgsm.com/alerts/rocket.chat
+rocketchatalert="off"
+rocketchatwebhook="webhook"
+
+# Slack Alerts | https://docs.linuxgsm.com/alerts/slack
+slackalert="off"
+slackwebhook="webhook"
+
+# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram
+# You can add a custom cURL string eg proxy (useful in Russia) in "curlcustomstring".
+# For example "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help all".
+telegramapi="api.telegram.org"
+telegramalert="off"
+telegramtoken="accesstoken"
+telegramchatid=""
+telegramthreadid=""
+telegramsilentnotification="false"
+curlcustomstring=""
+
+## Stop | https://docs.linuxgsm.com/commands/start-stop-restart
+stoponlyifnoplayers="off"
+stoponlyifnoplayersallcommands="on"
+
+## Player Warnings | https://docs.linuxgsm.com/features/player-warnings
+# Minutes to warn players in-game before a stop, restart or update. 0 to disable.
+# e.g. 15 warns at 15, 10, 5, 3 and 1 minutes.
+warnplayerstimer="0"
+
+## Updating | https://docs.linuxgsm.com/commands/update
+updateonstart="off"
+
+## Backup | https://docs.linuxgsm.com/commands/backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://docs.linuxgsm.com/features/logging
+consolelogging="on"
+logdays="7"
+
+## Monitor | https://docs.linuxgsm.com/commands/monitor
+# Query delay time
+querydelay="5"
+
+## ANSI Colors | https://docs.linuxgsm.com/features/ansi-colors
+ansi="on"
+
+#### Advanced Settings ####
+
+## Message Display Time | https://docs.linuxgsm.com/features/message-display-time
+sleeptime="0.5"
+
+## Stop Mode | https://docs.linuxgsm.com/features/stop-mode
+# 1: tmux kill
+# 2: CTRL+c
+# 3: quit
+# 4: quit 120s
+# 5: stop
+# 6: q
+# 7: exit
+# 8: 7 Days to Die
+# 9: GoldSrc
+# 10: Avorion
+# 11: end
+# 12: shutdown
+# 13: soulmask
+# 14: Running With Rifles
+# 15: Rising World
+# 16: Conan Exiles
+stopmode="3"
+
+## Query mode
+# 1: session only
+# 2: gamedig (gsquery fallback)
+# 3: gamedig
+# 4: gsquery
+# 5: tcp
+querymode="3"
+querytype="gta5f"
+
+## Console type
+consoleverbose="yes"
+consoleinteract="yes"
+
+## Game Server Details
+# Do not edit
+gamename="FiveM"
+engine="cfx"
+glibc="null"
+
+#### Directories ####
+# Edit with care
+
+## Game Server Directories
+systemdir="${serverfiles}"
+executabledir="${serverfiles}"
+executable="./run.sh"
+servercfgdir="${systemdir}"
+servercfg="server.cfg"
+servercfgdefault="server.cfg"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${lgsmdir}/backup"
+
+## Logging Directories
+[ -n "${LGSM_LOGDIR}" ] && logdir="${LGSM_LOGDIR}" || logdir="${rootdir}/log"
+lgsmlogdir="${logdir}/script"
+consolelogdir="${logdir}/console"
+lgsmlog="${lgsmlogdir}/${selfname}-script.log"
+consolelog="${consolelogdir}/${selfname}-console.log"
+alertlog="${lgsmlogdir}/${selfname}-alert.log"
+postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
+
+## Logs Naming
+lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
+
+## Log Parameters
+logtimestamp="off"
+logtimestampformat="%Y-%m-%d %H:%M:%S"

+ 1 - 0
lgsm/data/almalinux-8.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/almalinux-9.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/centos-7.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/centos-8.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/centos-9.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/debian-10.csv

@@ -47,6 +47,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/debian-11.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/debian-12.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/debian-13.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod
 hcu

+ 1 - 0
lgsm/data/debian-9.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

BIN
lgsm/data/gameicons/fivem-icon.png


+ 1 - 0
lgsm/data/rhel-7.csv

@@ -49,6 +49,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/rhel-8.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/rhel-9.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/rocky-8.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/rocky-9.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic
 fctr
+fivem
 fof
 gmod,ncurses-libs.i686
 hcu

+ 1 - 0
lgsm/data/serverlist.csv

@@ -47,6 +47,7 @@ em,emserver,Empires Mod,ubuntu-26.04
 etl,etlserver,ET: Legacy,ubuntu-26.04
 ets2,ets2server,Euro Truck Simulator 2,ubuntu-26.04
 fctr,fctrserver,Factorio,ubuntu-26.04
+fivem,fivemserver,FiveM,ubuntu-26.04
 fof,fofserver,Fistful of Frags,ubuntu-26.04
 gmod,gmodserver,Garrys Mod,ubuntu-26.04
 hcu,hcuserver,HYPERCHARGE: Unboxed,ubuntu-26.04

+ 1 - 0
lgsm/data/ubuntu-16.04.csv

@@ -49,6 +49,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-18.04.csv

@@ -49,6 +49,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-20.04.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-22.04.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-23.04.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-23.10.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod,libtinfo5:i386
 hcu

+ 1 - 0
lgsm/data/ubuntu-24.04.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod
 hcu

+ 1 - 0
lgsm/data/ubuntu-26.04.csv

@@ -48,6 +48,7 @@ em
 etl
 ets2,libatomic1
 fctr
+fivem
 fof
 gmod
 hcu

+ 10 - 0
lgsm/modules/check_config.sh

@@ -45,3 +45,13 @@ elif [ "${shortname}" == "vh" ] && [ "${#serverpassword}" -le "4" ]; then
 	fn_print_fail_nl "serverpassword is to short (min 5 chars)"
 	fn_script_log_fail "serverpassword is to short (min 5 chars)"
 fi
+
+if [ "${shortname}" == "fivem" ] && [ -z "${licensekey}" ] && ! grep -qE "^[[:space:]]*(set[[:space:]]+)?sv_licenseKey[[:space:]]+\"?[^\" ]" "${servercfgfullpath}" 2> /dev/null; then
+	fn_print_fail_nl "FiveM license key is not set"
+	echo -e "* Get a free key from ${italic}https://portal.cfx.re/servers/registration-keys${default}"
+	echo -e "* Set licensekey=\"\" in ${configdirserver}/${selfname}.cfg"
+	fn_script_log_fail "FiveM license key is not set"
+	if [ "${commandname}" == "START" ] || [ "${commandname}" == "DEBUG" ]; then
+		core_exit.sh
+	fi
+fi

+ 2 - 0
lgsm/modules/command_check_update.sh

@@ -24,6 +24,8 @@ elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortna
 	update_pmc.sh
 elif [ "${shortname}" == "fctr" ]; then
 	update_fctr.sh
+elif [ "${shortname}" == "fivem" ]; then
+	update_fivem.sh
 elif [ "${shortname}" == "hyt" ]; then
 	update_hyt.sh
 elif [ "${shortname}" == "mta" ]; then

+ 2 - 0
lgsm/modules/command_install.sh

@@ -39,6 +39,8 @@ else
 		install_gslt.sh
 	elif [ "${shortname}" == "dst" ]; then
 		install_dst_token.sh
+	elif [ "${shortname}" == "fivem" ]; then
+		install_fivem_license.sh
 	elif [ "${shortname}" == "squad" ]; then
 		install_squad_license.sh
 	elif [ "${shortname}" == "ts3" ]; then

+ 2 - 0
lgsm/modules/command_update.sh

@@ -65,6 +65,8 @@ elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortna
 	update_pmc.sh
 elif [ "${shortname}" == "fctr" ]; then
 	update_fctr.sh
+elif [ "${shortname}" == "fivem" ]; then
+	update_fivem.sh
 elif [ "${shortname}" == "hyt" ]; then
 	update_hyt.sh
 elif [ "${shortname}" == "mta" ]; then

+ 2 - 2
lgsm/modules/core_getopt.sh

@@ -71,8 +71,8 @@ currentopt+=("${cmd_update_linuxgsm[@]}")
 if [ "${shortname}" == "jk2" ] || [ "${shortname}" == "jk3" ] || [ "${shortname}" == "etl" ] || [ "${engine}" != "idtech3" ]; then
 	if [ "${shortname}" != "bf1942" ] && [ "${shortname}" != "bfv" ] && [ "${engine}" != "idtech2" ] && [ "${engine}" != "iw2.0" ] && [ "${engine}" != "iw3.0" ] && [ "${engine}" != "quake" ] && [ "${shortname}" != "samp" ] && [ "${shortname}" != "ut2k4" ]; then
 		currentopt+=("${cmd_update[@]}" "${cmd_check_update[@]}")
-		# force update for SteamCMD, Multi Theft Auto or Hytale only.
-		if [ "${appid}" ] || [ "${shortname}" == "mta" ] || [ "${shortname}" == "hyt" ]; then
+		# force update for SteamCMD, Multi Theft Auto, Hytale or FiveM only.
+		if [ "${appid}" ] || [ "${shortname}" == "mta" ] || [ "${shortname}" == "hyt" ] || [ "${shortname}" == "fivem" ]; then
 			currentopt+=("${cmd_force_update[@]}")
 		fi
 	fi

+ 10 - 0
lgsm/modules/core_modules.sh

@@ -186,6 +186,11 @@ command_workshop_update.sh() {
 	fn_fetch_module
 }
 
+install_fivem_license.sh() {
+	modulefile="${FUNCNAME[0]}"
+	fn_fetch_module
+}
+
 install_squad_license.sh() {
 	modulefile="${FUNCNAME[0]}"
 	fn_fetch_module
@@ -732,6 +737,11 @@ update_fctr.sh() {
 	fn_fetch_module
 }
 
+update_fivem.sh() {
+	modulefile="${FUNCNAME[0]}"
+	fn_fetch_module
+}
+
 update_hyt.sh() {
 	modulefile="${FUNCNAME[0]}"
 	fn_fetch_module

+ 20 - 0
lgsm/modules/info_game.sh

@@ -1319,6 +1319,24 @@ fn_info_game_etl() {
 	serverpassword="${serverpassword:-"NOT SET"}"
 }
 
+# Config Type: Custom (key value pairs)
+# Comment: #
+# Example: sv_hostname "SERVERNAME"
+# Filetype: cfg
+fn_info_game_fivem() {
+	if [ -f "${servercfgfullpath}" ]; then
+		servername="$(sed -n 's/^sv_hostname[[:space:]]\+"\?\([^"]*\)"\?.*/\1/p' "${servercfgfullpath}" | head -1 | tr -d '\r')"
+		maxplayers="$(sed -n 's/^sv_maxclients[[:space:]]\+\([0-9]*\).*/\1/p' "${servercfgfullpath}" | head -1)"
+		rconpassword="$(sed -n 's/^rcon_password[[:space:]]\+"\?\([^"]*\)"\?.*/\1/p' "${servercfgfullpath}" | head -1 | tr -d '\r')"
+		port="$(sed -n 's/^endpoint_add_udp[[:space:]]\+"\?[^:"]*:\([0-9]*\)"\?.*/\1/p' "${servercfgfullpath}" | head -1)"
+	fi
+	maxplayers="${maxplayers:-"0"}"
+	port="${port:-"0"}"
+	queryport="${port}"
+	rconpassword="${rconpassword:-"NOT SET"}"
+	servername="${servername:-"NOT SET"}"
+}
+
 # Config Type: json
 # Parameters: true
 # Comment: // or /* */
@@ -2489,6 +2507,8 @@ elif [ "${shortname}" == "etl" ]; then
 	fn_info_game_etl
 elif [ "${shortname}" == "fctr" ]; then
 	fn_info_game_fctr
+elif [ "${shortname}" == "fivem" ]; then
+	fn_info_game_fivem
 elif [ "${shortname}" == "hw" ]; then
 	fn_info_game_hw
 elif [ "${shortname}" == "hz" ]; then

+ 17 - 1
lgsm/modules/info_messages.sh

@@ -64,6 +64,10 @@ fn_info_messages_password_strip() {
 		if [ "${gslt}" ]; then
 			gslt="********"
 		fi
+
+		if [ "${licensekey}" ]; then
+			licensekey="********"
+		fi
 	fi
 }
 
@@ -726,7 +730,7 @@ fn_info_messages_ports_edit() {
 
 	startparameterslocation="${red}UNKNOWN${default}"
 	# engines/games that require editing in the config file.
-	local ports_edit_array=("ac" "arma3" "armar" "bo" "bt" "ct" "dst" "eco" "idtech2" "idtech3" "idtech3_ql" "jc2" "jc3" "lwjgl2" "mcb" "nec" "pc" "pc2" "prism3d" "pz" "qw" "refractor" "renderware" "rw" "rwr" "sb" "sdtd" "st" "stn" "ts3" "tw" "terraria" "unreal" "unreal2" "unreal3" "vints" "xnt" "wurm")
+	local ports_edit_array=("ac" "arma3" "armar" "bo" "bt" "ct" "dst" "eco" "fivem" "idtech2" "idtech3" "idtech3_ql" "jc2" "jc3" "lwjgl2" "mcb" "nec" "pc" "pc2" "prism3d" "pz" "qw" "refractor" "renderware" "rw" "rwr" "sb" "sdtd" "st" "stn" "ts3" "tw" "terraria" "unreal" "unreal2" "unreal3" "vints" "xnt" "wurm")
 	for port_edit in "${ports_edit_array[@]}"; do
 		if [ "${shortname}" == "ut3" ]; then
 			startparameterslocation="${servercfgdir}/UTWeb.ini"
@@ -763,6 +767,8 @@ fn_info_messages_ports() {
 		portcommand="ss -tuplwn | grep enfMain"
 	elif [ "${shortname}" == "q4" ]; then
 		portcommand="ss -tuplwn | grep q4ded.x86"
+	elif [ "${shortname}" == "fivem" ]; then
+		portcommand="ss -tuplwn | grep ld-musl"
 	elif [ "${shortname}" == "rwr" ]; then
 		portcommand="ss -tuplwn | grep rwr_server"
 	elif [ "${shortname}" == "hyt" ] || [ "${shortname}" == "mc" ] || [ "${shortname}" == "nec" ] || [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortname}" == "wmc" ]; then
@@ -1109,6 +1115,14 @@ fn_info_messages_etl() {
 	} | column -s $'\t' -t
 }
 
+fn_info_messages_fivem() {
+	{
+		fn_port "header"
+		fn_port "Game" port tcp
+		fn_port "Game" port udp
+	} | column -s $'\t' -t
+}
+
 fn_info_messages_fctr() {
 	{
 		fn_port "header"
@@ -1918,6 +1932,8 @@ fn_info_messages_select_engine() {
 		fn_info_messages_etl
 	elif [ "${shortname}" == "fctr" ]; then
 		fn_info_messages_fctr
+	elif [ "${shortname}" == "fivem" ]; then
+		fn_info_messages_fivem
 	elif [ "${shortname}" == "hcu" ]; then
 		fn_info_messages_hcu
 	elif [ "${shortname}" == "hw" ]; then

+ 5 - 0
lgsm/modules/install_config.sh

@@ -482,6 +482,11 @@ elif [ "${shortname}" == "fctr" ]; then
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
+elif [ "${shortname}" == "fivem" ]; then
+	array_configs+=(server.cfg)
+	fn_default_config_remote
+	fn_set_config_vars
+	fn_list_config_locations
 elif [ "${shortname}" == "fof" ]; then
 	array_configs+=(server.cfg)
 	fn_default_config_remote

+ 24 - 0
lgsm/modules/install_fivem_license.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+# LinuxGSM install_fivem_license.sh module
+# Author: Daniel Gibbs
+# Contributors: https://linuxgsm.com/contrib
+# Website: https://linuxgsm.com
+# Description: Explains how to set the FiveM server license key.
+
+moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+echo -e ""
+echo -e "${bold}${lightyellow}${gamename} License Key${default}"
+fn_messages_separator
+echo -e "A license key is required to run a ${gamename} server."
+fn_script_log_info "A license key is required to run a ${gamename} server."
+
+echo -e "Get a free license key here:"
+echo -e "${italic}https://portal.cfx.re/servers/registration-keys${default}"
+fn_script_log_info "Get a free license key here:"
+fn_script_log_info "https://portal.cfx.re/servers/registration-keys"
+echo -e ""
+fn_sleep_time_1
+echo -e "Set the license key by adding licensekey=\"\" to ${configdirserver}/${selfname}.cfg."
+fn_script_log_info "Set the license key by adding licensekey=\"\" to ${configdirserver}/${selfname}.cfg."
+echo -e ""

+ 2 - 0
lgsm/modules/install_server_files.sh

@@ -257,6 +257,8 @@ elif [ "${shortname}" == "mta" ]; then
 elif [ "${shortname}" == "fctr" ]; then
 	update_fctr.sh
 	install_factorio_save.sh
+elif [ "${shortname}" == "fivem" ]; then
+	update_fivem.sh
 elif [ "${shortname}" == "hyt" ]; then
 	update_hyt.sh
 elif [ "${shortname}" == "jk2" ]; then

+ 139 - 0
lgsm/modules/update_fivem.sh

@@ -0,0 +1,139 @@
+#!/bin/bash
+# LinuxGSM update_fivem.sh module
+# Author: Daniel Gibbs
+# Contributors: https://linuxgsm.com/contrib
+# Website: https://linuxgsm.com
+# Description: Handles updating of FiveM servers.
+
+moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+fn_update_resources() {
+	# Download and extract the cfx-server-data base resources.
+	fn_fetch_file "https://github.com/citizenfx/cfx-server-data/archive/refs/heads/master.tar.gz" "" "" "" "${tmpdir}" "cfx-server-data.tar.gz" "nochmodx" "norun" "force" "nohash"
+	fn_dl_extract "${tmpdir}" "cfx-server-data.tar.gz" "${serverfiles}" "cfx-server-data-master/resources"
+}
+
+fn_update_dl() {
+	# Download and extract files to tmpdir.
+	fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "nochmodx" "norun" "force" "nohash"
+	rm -rf "${serverfiles:?}/alpine"
+	fn_dl_extract "${tmpdir}" "${remotebuildfilename}" "${serverfiles}"
+	if [ ! -d "${serverfiles}/resources" ]; then
+		fn_update_resources
+	fi
+	echo "${remotebuild}" > "${localbuildfile}"
+	fn_clear_tmp
+}
+
+fn_update_localbuild() {
+	# Gets local build info.
+	fn_print_dots "Checking local build: ${remotelocation}"
+	if [ -f "${localbuildfile}" ]; then
+		localbuild="$(cat "${localbuildfile}")"
+	fi
+	if [ -z "${localbuild}" ]; then
+		fn_print_error "Checking local build: ${remotelocation}: missing local build info"
+		fn_script_log_error "Missing local build info"
+		fn_script_log_error "Set localbuild to 0"
+		localbuild="0"
+	else
+		fn_print_ok "Checking local build: ${remotelocation}"
+		fn_script_log_pass "Checking local build"
+	fi
+}
+
+fn_update_remotebuild() {
+	# Gets remote build info.
+	apiurl="https://changelogs-live.fivem.net/api/changelog/versions/linux/server"
+	remotebuildresponse=$(curl -s "${apiurl}")
+	remotebuild=$(echo "${remotebuildresponse}" | jq -r '.recommended')
+	remotebuildurl=$(echo "${remotebuildresponse}" | jq -r '.recommended_download')
+	remotebuildfilename="fx.tar.xz"
+	if [ "${firstcommandname}" != "INSTALL" ]; then
+		fn_print_dots "Checking remote build: ${remotelocation}"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ] || [ -z "${remotebuildurl}" ] || [ "${remotebuildurl}" == "null" ]; then
+			fn_print_fail "Checking remote build: ${remotelocation}"
+			fn_script_log_fail "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking remote build: ${remotelocation}"
+			fn_script_log_pass "Checking remote build"
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ] || [ -z "${remotebuildurl}" ] || [ "${remotebuildurl}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fail "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_compare() {
+	fn_print_dots "Checking for update: ${remotelocation}"
+	# Update has been found or force update.
+	if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then
+		# Create update lockfile.
+		date '+%s' > "${lockdir:?}/update.lock"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		fn_print "\n"
+		fn_print_nl "${bold}${underline}Update${default} available"
+		fn_print_nl "* Local build: ${red}${localbuild}${default}"
+		fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
+		if [ -f "${rootdir}/.dev-debug" ]; then
+			fn_print_nl "Remote build info"
+			fn_print_nl "* apiurl: ${apiurl}"
+			fn_print_nl "* remotebuildfilename: ${remotebuildfilename}"
+			fn_print_nl "* remotebuildurl: ${remotebuildurl}"
+			fn_print_nl "* remotebuild: ${remotebuild}"
+		fi
+		fn_print "\n"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
+
+		if [ "${commandname}" == "UPDATE" ]; then
+			unset updateonstart
+			fn_update_apply fn_update_dl
+			alert="update"
+		elif [ "${commandname}" == "CHECK-UPDATE" ]; then
+			alert="check-update"
+		fi
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		fn_print "\n"
+		fn_print_nl "${bold}${underline}No update${default} available"
+		fn_print_nl "* Local build: ${green}${localbuild}${default}"
+		fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
+		fn_print "\n"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		if [ -f "${rootdir}/.dev-debug" ]; then
+			fn_print_nl "Remote build info"
+			fn_print_nl "* apiurl: ${apiurl}"
+			fn_print_nl "* remotebuildfilename: ${remotebuildfilename}"
+			fn_print_nl "* remotebuildurl: ${remotebuildurl}"
+			fn_print_nl "* remotebuild: ${remotebuild}"
+		fi
+	fi
+}
+
+localbuildfile="${datadir}/${selfname}-fivem-version"
+# The location where the builds are checked and downloaded.
+remotelocation="runtime.fivem.net"
+
+if [ "${firstcommandname}" == "INSTALL" ]; then
+	fn_update_remotebuild
+	fn_update_dl
+else
+	fn_print_dots "Checking for update"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
+	fn_update_localbuild
+	fn_update_remotebuild
+	fn_update_compare
+fi