From 391eacb472f47373388e10dc16d2a7bb03201570 Mon Sep 17 00:00:00 2001 From: Greelan <53196309+Greelan@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:17:14 +1000 Subject: [PATCH] Space Engineers: add Linux support (#400) --- space-engineers-generic.kvp | 39 +++++++---- space-engineers-genericupdates.json | 99 ++++++++++++++++------------ space-engineers-genericwinescript.sh | 33 ++++++++++ 3 files changed, 116 insertions(+), 55 deletions(-) create mode 100644 space-engineers-genericwinescript.sh diff --git a/space-engineers-generic.kvp b/space-engineers-generic.kvp index 5fbf42e..144c863 100644 --- a/space-engineers-generic.kvp +++ b/space-engineers-generic.kvp @@ -1,32 +1,39 @@ Meta.DisplayName=Space Engineers Meta.Description=Space Engineers Dedicated Server -Meta.OS=Windows +Meta.OS=Windows, Linux +Meta.AarchSupport=Unknown Meta.Arch=x86_64 -Meta.Author=IceOfWraith, CubeCoders(base) +Meta.Author=IceOfWraith, Greelan, CubeCoders(base) Meta.URL=https://store.steampowered.com/app/244850/Space_Engineers/ Meta.DisplayImageSource=steam:244850 -Meta.EndpointURIFormat=steam://connect/{ip}:{GenericModule.App.ApplicationPort2} +Meta.EndpointURIFormat=steam://connect/{ip}:{GenericModule.App.Ports.$ApplicationPort1} Meta.ConfigManifest=space-engineers-genericconfig.json Meta.MetaConfigManifest=space-engineers-genericmetaconfig.json Meta.ConfigRoot=space-engineers-generic.kvp -Meta.MinAMPVersion=2.4.0.10 -Meta.SpecificDockerImage= +Meta.MinAMPVersion=2.4.3.0 +Meta.SpecificDockerImage=cubecoders/ampbase:wine8 Meta.DockerRequired=False -Meta.ContainerPolicy=NotSupported -Meta.ContainerPolicyReason=This game has dependencies that are not currently supported by AMP. +Meta.ContainerPolicy=SupportedOnWindows, RecommendedOnLinux +Meta.ContainerPolicyReason=The server requires Wine 8 (or later), Xvfb and cabextract to install and run on Linux. Using a container avoids the need to install these dependencies on the host. +Meta.ExtraSetupStepsURI= Meta.Prerequsites=[] Meta.ExtraContainerPackages=[] Meta.ConfigReleaseState=NotSpecified Meta.NoCommercialUsage=False +Meta.ConfigVersion=0.0.0.0 +Meta.ReleaseNotes= +Meta.BreakingReleaseNotes= App.DisplayName=Space Engineers App.RootDir=./space-engineers-generic/ App.BaseDirectory=./space-engineers-generic/298740/ +App.SteamWorkshopDownloadLocation= App.ExecutableWin=298740\DedicatedServer64\SpaceEngineersDedicated.exe -App.ExecutableLinux= +App.ExecutableLinux=/usr/bin/wine App.WorkingDir=298740/DedicatedServer64 -App.LinuxCommandLineArgs= +App.LinuxCommandLineArgs="./SpaceEngineersDedicated.exe" App.WindowsCommandLineArgs= App.CommandLineArgs={{$PlatformArgs}} -console -path "{{$FullBaseDir}}servers" {{$FormattedArgs}} +App.UseLinuxIOREDIR=False App.AppSettings={} App.EnvironmentVariables={"LD_LIBRARY_PATH":"./linux64:%LD_LIBRARY_PATH%","SteamAppId":"244850","WINEPREFIX":"{{$FullRootDir}}.wine","WINEARCH":"win64","WINEDEBUG":"-all"} App.CommandLineParameterFormat=-{0} "{1}" @@ -47,29 +54,33 @@ App.UniversalSleepApplicationUDPPortRef=ApplicationPort1 App.UniversalSleepSteamQueryPortRef=ApplicationPort2 App.MaxUsers=4 App.UseRandomAdminPassword=False -App.RemoteAdminPassword=Password123 +App.PersistRandomPassword=True +App.RemoteAdminPassword= App.AdminMethod=STDIO App.AdminLoginTransform=None +App.LoginTransformPrefix= App.RCONConnectDelaySeconds=5 App.RCONConnectRetrySeconds=5 App.RCONHeartbeatMinutes=0 App.RCONHeartbeatCommand=ping App.TelnetLoginFormat={0} App.UpdateSources=@IncludeJson[space-engineers-genericupdates.json] +App.PreStartStages=[] App.Compatibility=None App.SteamUpdateAnonymousLogin=True App.SteamForceLoginPrompt=False App.RapidStartup=False +App.MonitorChildProcess=True +App.DumpFullChildProcessTree=False +App.MonitorChildProcessWaitMs=1000 +App.MonitorChildProcessName=SpaceEngineersDedicated.exe App.SupportsUniversalSleep=True App.WakeupMode=Any App.ApplicationReadyMode=RegexMatch App.TemplateMatchRegex={{(\$?[\w]+)}} -App.MonitorChildProcess=True -App.MonitorChildProcessWaitMs=3000 -App.MonitorChildProcessName=wine64 Console.FilterMatchRegex= Console.FilterMatchReplacement= -Console.ThrowawayMessageRegex=^(WARNING|ERROR): Shader.+$ +Console.ThrowawayMessageRegex=^(WARNING|ERROR): Shader.+|.+\|WARN\|GameAnalyticsSDK\.Net\.Logging\.GALogger\|Warning\/GameAnalytics: Event queue: Failed to send events to collector - Retrying next time$ Console.AppReadyRegex=^\d+\-\d+\-\d+ \d+\:\d+\:\d+.\d+\: Game ready.*$ Console.UserJoinRegex=^\d+\-\d+\-\d+ \d+\:\d+\:\d+.\d+\: World request received: (?.+?)$ Console.UserLeaveRegex=^\d+\-\d+\-\d+ \d+\:\d+\:\d+.\d+\: User left (?.+?)$ diff --git a/space-engineers-genericupdates.json b/space-engineers-genericupdates.json index a201d42..52ddebb 100644 --- a/space-engineers-genericupdates.json +++ b/space-engineers-genericupdates.json @@ -1,57 +1,74 @@ [ { - "UpdateStageName": "SteamCMD Download", - "UpdateSourcePlatform": "All", - "UpdateSource": "SteamCMD", - "UpdateSourceData": "298740", - "UpdateSourceArgs": "244850", - "UpdateSourceVersion": "{{Stream}}" + "UpdateStageName":"SteamCMD Download", + "UpdateSourcePlatform":"All", + "UpdateSource":"SteamCMD", + "UpdateSourceData":"298740", + "UpdateSourceArgs":"244850", + "UpdateSourceVersion":"{{Stream}}", + "ForceDownloadPlatform":"Windows" }, { - "UpdateStageName": "Create Config Directory", - "UpdateSourcePlatform": "All", - "UpdateSource": "CreateDirectory", - "UpdateSourceArgs": "{{$FullBaseDir}}servers", - "OverwriteExistingFiles": false + "UpdateStageName":"Create Config Directory", + "UpdateSourcePlatform":"All", + "UpdateSource":"CreateDirectory", + "UpdateSourceArgs":"{{$FullBaseDir}}servers", + "OverwriteExistingFiles":false }, { - "UpdateStageName": "Base Config Download", - "UpdateSourcePlatform": "All", - "UpdateSource": "FetchURL", - "UpdateSourceData": "https://github.com/CubeCoders/AMPTemplates/raw/main/space-engineers-dedicated.cfg", - "UpdateSourceTarget": "{{$FullBaseDir}}servers", - "UpdateSourceArgs": "SpaceEngineers-Dedicated.cfg", - "OverwriteExistingFiles": false + "UpdateStageName":"Base Config Download", + "UpdateSourcePlatform":"All", + "UpdateSource":"FetchURL", + "UpdateSourceData":"https://github.com/CubeCoders/AMPTemplates/raw/main/space-engineers-dedicated.cfg", + "UpdateSourceTarget":"{{$FullBaseDir}}servers", + "UpdateSourceArgs":"SpaceEngineers-Dedicated.cfg", + "OverwriteExistingFiles":false }, { - "UpdateStageName": "Mods Workaround 1", - "UpdateSourcePlatform": "All", - "UpdateSource": "CopyFilePath", - "UpdateSourceData": "{{$FullBaseDir}}DedicatedServer64/steamclient64.dll", - "UpdateSourceArgs": "{{$FullBaseDir}}steamclient64.dll", - "OverwriteExistingFiles": true + "UpdateStageName":"Mods Workaround 1", + "UpdateSourcePlatform":"All", + "UpdateSource":"CopyFilePath", + "UpdateSourceData":"{{$FullBaseDir}}DedicatedServer64/steamclient64.dll", + "UpdateSourceArgs":"{{$FullBaseDir}}steamclient64.dll", + "OverwriteExistingFiles":true }, { - "UpdateStageName": "Mods Workaround 2", - "UpdateSourcePlatform": "All", - "UpdateSource": "CopyFilePath", - "UpdateSourceData": "{{$FullBaseDir}}DedicatedServer64/tier0_s64.dll", - "UpdateSourceArgs": "{{$FullBaseDir}}tier0_s64.dll", - "OverwriteExistingFiles": true + "UpdateStageName":"Mods Workaround 2", + "UpdateSourcePlatform":"All", + "UpdateSource":"CopyFilePath", + "UpdateSourceData":"{{$FullBaseDir}}DedicatedServer64/tier0_s64.dll", + "UpdateSourceArgs":"{{$FullBaseDir}}tier0_s64.dll", + "OverwriteExistingFiles":true }, { - "UpdateStageName": "Mods Workaround 3", - "UpdateSourcePlatform": "All", - "UpdateSource": "CopyFilePath", - "UpdateSourceData": "{{$FullBaseDir}}DedicatedServer64/vstdlib_s64.dll", - "UpdateSourceArgs": "{{$FullBaseDir}}vstdlib_s64.dll", - "OverwriteExistingFiles": true + "UpdateStageName":"Mods Workaround 3", + "UpdateSourcePlatform":"All", + "UpdateSource":"CopyFilePath", + "UpdateSourceData":"{{$FullBaseDir}}DedicatedServer64/vstdlib_s64.dll", + "UpdateSourceArgs":"{{$FullBaseDir}}vstdlib_s64.dll", + "OverwriteExistingFiles":true }, { - "UpdateStageName":" Initialise Wine", - "UpdateSourcePlatform": "Linux", - "UpdateSource": "Executable", - "UpdateSourceData": "/bin/bash", - "UpdateSourceArgs": "-c 'WINEPREFIX=\"{{$FullRootDir}}.wine\" WINEARCH=win64 /usr/bin/wineboot --init --update'" + "UpdateStageName":"Initialise Wine", + "UpdateSourcePlatform":"Linux", + "UpdateSource":"Executable", + "UpdateSourceData":"/bin/bash", + "UpdateSourceArgs":"-c 'WINEPREFIX=\"{{$FullRootDir}}.wine\" WINEARCH=win64 WINEDEBUG=-all WINEDLLOVERRIDES=\"mscoree,mshtml=\" /usr/bin/wineboot --init --update'" + }, + { + "UpdateStageName":"Winescript Download", + "UpdateSourcePlatform":"Linux", + "UpdateSource":"FetchURL", + "UpdateSourceData":"https://raw.githubusercontent.com/CubeCoders/AMPTemplates/main/space-engineers-genericwinescript.sh", + "UpdateSourceArgs":"winescript.sh", + "UpdateSourceTarget":"{{$FullInstanceDir}}", + "OverwriteExistingFiles":true + }, + { + "UpdateStageName":"Install Windows Components", + "UpdateSourcePlatform":"Linux", + "UpdateSource":"Executable", + "UpdateSourceData":"/bin/bash", + "UpdateSourceArgs":"./winescript.sh" } ] diff --git a/space-engineers-genericwinescript.sh b/space-engineers-genericwinescript.sh new file mode 100644 index 0000000..16f1303 --- /dev/null +++ b/space-engineers-genericwinescript.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +SCRIPT_NAME=$(echo \"$0\" | xargs readlink -f) +SCRIPTDIR=$(dirname "$SCRIPT_NAME") + +exec 6>display.log +/usr/bin/Xvfb -displayfd 6 & +XVFB_PID=$! +while [[ ! -s display.log ]]; do + sleep 1 +done +read -r DPY_NUM < display.log +rm display.log + +wget -N https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks +chmod +x winetricks + +export WINEPREFIX="$SCRIPTDIR/space-engineers-generic/.wine" +export WINEDLLOVERRIDES="mscoree,mshtml=" +export WINEARCH=win64 +export WINEDEBUG=fixme-all +export DISPLAY=:$DPY_NUM +./winetricks corefonts > winescript_log.txt 2>&1 +./winetricks sound=disabled >> winescript_log.txt 2>&1 +./winetricks -q vcrun2013 >> winescript_log.txt 2>&1 +./winetricks -q vcrun2019 >> winescript_log.txt 2>&1 +./winetricks -q dotnet48 >> winescript_log.txt 2>&1 +rm -rf ~/.cache/winetricks ~/.cache/fontconfig + +exec 6>&- +kill $XVFB_PID + +exit 0