FiveM Automatic Updater

FiveM-Update

This is a script that will keep your server up-to-date when run on a schedule. See the README for full details, but essentially you just modify what folder it should look in and it will do the rest.

Github

Windows only for now (as it uses Powershell). Once I can build a test Linux box I will develop something there, or someone else can contribute :slight_smile:

If you encounter any problems, feel free to post to this topic or create a Github issue. Enjoy.

UPDATED

Released v1.1 which fixes the script removing old files before successfully downloading the new one. Also adds -KeepDownload option if you wish to hold onto the downloaded updates for whatever reason.

4 Likes

but…

1 Like

I wouldn’t worry about building a “test Linux box”, since the elements aren’t in any big hurry to build or maintain theirs either. Consequently, Linux updates have been a little spotty (in comparison to Windows build updates).

Well, I should say untested in Linux. I’ll look into that to see if it’s enough.

might wanna add this to the first line in the Get-Latest-Release

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
function Get-Latest-Release {
	[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
    $obj = Invoke-WebRequest "https://api.github.com/repos/citizenfx/fivem/git/refs/tags" -Headers @{"accept"="application/vnd.github.v3+json"} -UseBasicParsing | ConvertFrom-Json
    $path = ($obj | Select-Object -Last 1).object.url
    $tag = (Invoke-WebRequest $path -Headers @{"accept"="application/vnd.github.v3+json"} -UseBasicParsing) | ConvertFrom-Json 
    $hash = $tag.object.url -replace "https://api.github.com/repos/citizenfx/fivem/git/commits/"
    $version = $tag.tag -replace "v1.0.0."
    $fullUrl = "https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/" + $version + "-" + $hash + "/server.zip"
    $releaseObj = New-Object -TypeName psobject
    $releaseObj | Add-Member -MemberType NoteProperty -Name Uri -Value $fullUrl 
    $releaseObj | Add-Member -MemberType NoteProperty -Name Version -Value $version
    $releaseObj | Add-Member -MemberType NoteProperty -Name Hash -Value $hash
    return $releaseObj
}

Good point.

I enjoy my Linux machines.

Ill do a guinea pig round for you when I get up tomorrow.

CentOS7 will be the playground.

:kissing_heart:

1 Like

Not sure if Linux support will be added. Linux builds are inconsistent and the script can only find the latest version by tag (can’t parse the actual list on the download page anymore)…unless someone has a better way.

I’ll have a crack at it anyway.

Worst case, I build a quick python bot to loop scrape the build links and check the for the highest number and only take that string and vs the server version with it.

I’ll let you know how I go with the testing eitherway.

You can’t scrape the build links anymore due to cloudflare which is why my script uses the Github API.

Tehehe.

:yum:

I like a challenge.

1 Like

A couple of months ago I gave up on developing an auto updater because for me it was pretty clear that the FiveM team didn’t wanted one.
The fact that they have cloudflare “turned up to 11” in the server artifacts page and not in the client page indicates that the protection is not there because of DDoS.

Hope they changed their mind.

Probably because scraping the page was something they didn’t want due to load. That’s why this script uses Github’s API to find the releases and generate the direct download link. Much less load that way.

If it was just the load he could let the caching & ddos protection on just like any other page/endpoint.
This isn’t for load protection.

Nice release, definitely will be using this!

UPDATED

Released v1.1 which fixes the script removing old files before successfully downloading the new one. Also adds -KeepDownload option if you wish to hold onto the downloaded updates for whatever reason.

Full changelog:

  • Ensure new artifact can be downloaded before removing old files
  • Exempt .zip files from purge
  • Added -KeepDownload flag, specifying will keep the newly downloaded artifact zip.
  • Exempt .crt and .key from purge so custom-signed certs are never deleted.

As always, you can find releases here.

Sorry for the stupid question, but my English and coding skills are zero.

Do I understand the script correctly and it updates the game content to the current version of the game?