Jump to content

Conan Exiles Server Utility


Dateranoth
 Share

Recommended Posts

  • Replies 261
  • Created
  • Last Reply

Top Posters In This Topic

V2.3.0.0 Update!

This release adds some features and corrects some possible issues.

  • Enable or Disable Verification every time SteamCMD runs
  • Check for update every 5 to 59 minutes
  • Notification if INI file options don't match
  • Notification if duplicate appmanifest detected.

 

V2.3.0.0 Downloads

Complete Version 2.3.0.0 including Source

Conan Server Utility V2.3.0.0

Conan Server Remote Restart Utility V2.3.0.0

Conan Server Utility V2.3.0.0 Source

Conan Server Remote Restart Utility V2.3.0.0 Source

 

V2.3.0.0 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 8, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.3.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 8, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
	Local $iniArray = IniReadSectionNames("ConanServerUtility.ini")
	Local $iniLength = UBound($iniArray)
	If $iniLength <> 22 Then
		MsgBox(4096, "ERROR: INI INCORRECT", "ConanServerUtility.ini missing section. Please delete and recreate default.")
		Exit
	EndIf
   Local $BindIP = IniRead("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "7777")
   Local $QueryPort = IniRead("ConanServerUtility.ini", "Steam Query Port", "QueryPort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $validategame = IniRead("ConanServerUtility.ini", "Validate Files Every Time SteamCMD Runs? yes/no", "validategame", "yes")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every X Minutes? yes/no", "CheckForUpdate", "yes")
   Local $UpdateInterval = IniRead("ConanServerUtility.ini", "Update Check Interval in Minutes 05-59", "UpdateInterval", "59")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   Local $SteamFix = IniRead("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
Else
   IniWrite("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "7777")
   IniWrite("ConanServerUtility.ini", "Steam Query Port", "QueryPort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Validate Files Every Time SteamCMD Runs? yes/no", "validategame", "yes")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every X Minutes? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Update Check Interval in Minutes 05-59", "UpdateInterval", "59")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   IniWrite("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

If $UpdateInterval < 5 OR $UpdateInterval > 59 AND $CheckForUpdate = "yes" Then
	MsgBox(4096, "Invalid Interval", "Update Interval Minimum 5 and Maximum 59 . Please Modify Interval or disable Update Check")
	Exit
EndIf

OnAutoItExitRegister("Gamercide")
Global $mNextCheck = 0
Global $sFile = ""
Global $Server_EXE = "ConanSandboxServer-Win64-Test.exe"
Global $PIDFile = @ScriptDir &"\ConanServerUtility_lastpid_tmp"
Global $hWndFile = @ScriptDir &"\ConanServerUtility_lasthwnd_tmp"
If FileExists($PIDFile) Then
	Global $ConanPID = FileRead($PIDFile)
	Global $ConanhWnd = HWnd(FileRead($hWndFile))
Else
	Global $ConanPID = "0"
	Global $ConanhWnd = "0"
EndIf

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" Server Shutdown by User Input from ConanServerUtility Script")
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",2)
	EndIf
	If $UseRemoteRestart = "yes" Then
		TCPShutdown()
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists($ConanPID)
	ControlSend($ConanhWnd, "", "", "I" & @CR)
	ControlSend($ConanhWnd, "", "", "I" & @CR)
	ControlSend($ConanhWnd, "", "", "^C")
	WinWaitClose($ConanhWnd, "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
	FileDelete($PIDFile)
	FileDelete($hWndFile)
EndFunc

Func GetRSS()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	$sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)
EndFunc

Func ParseRSS()
	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"\ConanServerUtility_LastUpdate.txt"
	For $oName In $oNames

		If StringRegExp($oName.text,$cDate&"(?i)") Then
				If FileRead($cFile) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					ExitLoop
				Else
					FileDelete($cFile)
					FileWrite($cFile,$oName.text)
					Local $PID = ProcessExists($ConanPID)
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" ["& $oName.text &"] Restart for Update Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
EndFunc

Func CheckInterval()
	$mNextCheck = (@MIN + $UpdateInterval)
	If $mNextCheck >= 60 Then
		$mNextCheck = ($mNextCheck - 60)
	EndIf
	If $mNextCheck = @MIN Then
		$mNextCheck = ($mNextCheck - 1)
	EndIf
EndFunc

Func UpdateCheck()
	GetRSS()
	ParseRSS()
	FileDelete($sFile)
	CheckInterval()
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf
	Local $sManifestExists = FileExists($steamcmddir &"\steamapps\appmanifest_443030.acf")
		If $sManifestExists = 1 Then
			Local $manifestFound = MsgBox (4100, "Warning", "Install manifest found at "& $steamcmddir &"\steamapps\appmanifest_443030.acf"& @CRLF & @CRLF &"Suggest moving file to "& _
			$serverdir &"\steamapps\appmanifest_443030.acf before running SteamCMD"& @CRLF & @CRLF &"Would you like to Exit Now?",20)
			If $manifestFound = 6 Then
				Exit
			EndIf
		EndIf
Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

If $CheckForUpdate = "yes" Then
	CheckInterval()
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
$PassCompare = StringCompare($RECV, $RestartCode, 1)
   If $PassCompare = 0 Then
	  Local $PID = ProcessExists($ConanPID) ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
	    Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD: "& $RECV)
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists($ConanPID)
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		If $validategame = "yes" Then
			RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
		Else
			RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 +quit")
		EndIf
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	If $BindIP = "no" Then
		$ConanPID = Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?Port="& $GamePort &"?QueryPort="& $QueryPort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Else
		$ConanPID = Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?MULTIHOME="& $g_IP &"?Port="& $GamePort &"?QueryPort="& $QueryPort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	EndIf
	$ConanhWnd = WinGetHandle(WinWait(""& $serverdir &"", "", 70))
	If $SteamFix = "yes" Then
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
	EndIf
	FileDelete($PIDFile)
	FileDelete($hWndFile)
	FileWrite($PIDFile,$ConanPID)
	FileWrite($hWndFile,String($ConanhWnd))
	FileSetAttrib($PIDFile,"+HT")
	FileSetAttrib($hWndFile,"+HT")
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists($ConanPID)
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $mNextCheck And $CheckForUpdate = "yes" Then
	UpdateCheck()
	;Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Link to comment
Share on other sites

V2.3.0.1 Update!

BUG FIX RELEASE!!! This is to correct server not updating due to wrong expression match.

 

V2.3.0.1 Downloads

Complete Version 2.3.0.1 including Source

Conan Server Utility V2.3.0.1

Conan Server Remote Restart Utility V2.3.0.1

Conan Server Utility V2.3.0.1 Source

Conan Server Remote Restart Utility V2.3.0.1 Source

 

V2.3.0.1 Server Utility Source:

Spoiler

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#AutoIt3Wrapper_Res_Comment=By Dateranoth - Feburary 8, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Conan Server
#AutoIt3Wrapper_Res_Fileversion=2.3.0.1
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;By Dateranoth - Feburary 8, 2017
;Used by https://gamercide.com on their server
;Feel free to change, adapt, and distribute

#include <Date.au3>
#include <Process.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

;User Variables
If FileExists("ConanServerUtility.ini") Then
	Local $iniArray = IniReadSectionNames("ConanServerUtility.ini")
	Local $iniLength = UBound($iniArray)
	If $iniLength <> 22 Then
		MsgBox(4096, "ERROR: INI INCORRECT", "ConanServerUtility.ini missing section. Please delete and recreate default.")
		Exit
	EndIf
   Local $BindIP = IniRead("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   Local $g_IP = IniRead("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   Local $GamePort = IniRead("ConanServerUtility.ini", "Game Server Port", "GamePort", "7777")
   Local $QueryPort = IniRead("ConanServerUtility.ini", "Steam Query Port", "QueryPort", "27015")
   Local $AdminPass = IniRead("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   Local $MaxPlayers = IniRead("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   Local $serverdir = IniRead("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   Local $UseSteamCMD = IniRead("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   Local $steamcmddir = IniRead("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   Local $validategame = IniRead("ConanServerUtility.ini", "Validate Files Every Time SteamCMD Runs? yes/no", "validategame", "yes")
   Local $UseRemoteRestart = IniRead("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   Local $g_Port = IniRead("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   Local $RestartCode = IniRead("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   Local $RestartDaily = IniRead("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   Local $CheckForUpdate = IniRead("ConanServerUtility.ini", "Check for Update Every X Minutes? yes/no", "CheckForUpdate", "yes")
   Local $UpdateInterval = IniRead("ConanServerUtility.ini", "Update Check Interval in Minutes 05-59", "UpdateInterval", "59")
   Local $HotHour1 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   Local $HotHour2 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   Local $HotHour3 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   Local $HotHour4 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   Local $HotHour5 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   Local $HotHour6 = IniRead("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   Local $HotMin = IniRead("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   Local $ExMem = IniRead("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   Local $ExMemRestart = IniRead("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   Local $SteamFix = IniRead("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
Else
   IniWrite("ConanServerUtility.ini", "Use MULTIHOME to Bind IP? Disable if having connection issues (yes/no)", "BindIP", "yes")
   IniWrite("ConanServerUtility.ini", "Game Server IP", "ListenIP", "127.0.0.1")
   IniWrite("ConanServerUtility.ini", "Game Server Port", "GamePort", "7777")
   IniWrite("ConanServerUtility.ini", "Steam Query Port", "QueryPort", "27015")
   IniWrite("ConanServerUtility.ini", "Admin Password", "AdminPass", "yOuRpaSHeRe")
   IniWrite("ConanServerUtility.ini", "Max Players", "MaxPlayers", "20")
   IniWrite("ConanServerUtility.ini", "Server Directory. NO TRAILING SLASH", "serverdir", "C:\Game_Servers\Conan_Exiles_Server")
   IniWrite("ConanServerUtility.ini", "Use SteamCMD To Update Server? yes/no", "UseSteamCMD", "yes")
   IniWrite("ConanServerUtility.ini", "SteamCMD Directory. NO TRAILING SLASH", "steamcmddir", "C:\Game_Servers\SteamCMD")
   IniWrite("ConanServerUtility.ini", "Validate Files Every Time SteamCMD Runs? yes/no", "validategame", "yes")
   IniWrite("ConanServerUtility.ini", "Use Remote Restart ?yes/no", "UseRemoteRestart", "no")
   IniWrite("ConanServerUtility.ini", "Remote Restart Port", "ListenPort", "57520")
   IniWrite("ConanServerUtility.ini", "Remote Restart Password", "RestartCode", "FVtb2DXgp8SYwj7J")
   IniWrite("ConanServerUtility.ini", "Restart Server Daily? yes/no", "RestartDaily", "no")
   IniWrite("ConanServerUtility.ini", "Check for Update Every X Minutes? yes/no", "CheckForUpdate", "yes")
   IniWrite("ConanServerUtility.ini", "Update Check Interval in Minutes 05-59", "UpdateInterval", "59")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour1", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour2", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour3", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour4", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour5", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Hours? 00-23", "HotHour6", "00")
   IniWrite("ConanServerUtility.ini", "Daily Restart Minute? 00-59", "HotMin", "01")
   IniWrite("ConanServerUtility.ini", "Excessive Memory Amount?", "ExMem", "6000000000")
   IniWrite("ConanServerUtility.ini", "Restart On Excessive Memory Use? yes/no", "ExMemRestart", "no")
   IniWrite("ConanServerUtility.ini", "Running Server with Steam Open? (yes/no)", "SteamFix", "no")
   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")
   Exit
EndIf

If $UpdateInterval < 5 OR $UpdateInterval > 59 AND $CheckForUpdate = "yes" Then
	MsgBox(4096, "Invalid Interval", "Update Interval Minimum 5 and Maximum 59 . Please Modify Interval or disable Update Check")
	Exit
EndIf

OnAutoItExitRegister("Gamercide")
Global $mNextCheck = 0
Global $sFile = ""
Global $Server_EXE = "ConanSandboxServer-Win64-Test.exe"
Global $PIDFile = @ScriptDir &"\ConanServerUtility_lastpid_tmp"
Global $hWndFile = @ScriptDir &"\ConanServerUtility_lasthwnd_tmp"
If FileExists($PIDFile) Then
	Global $ConanPID = FileRead($PIDFile)
	Global $ConanhWnd = HWnd(FileRead($hWndFile))
Else
	Global $ConanPID = "0"
	Global $ConanhWnd = "0"
EndIf

Func Gamercide()
	If @exitMethod <> 1 Then
	$Shutdown = MsgBox(4100, "Shut Down?","Do you wish to shutdown the server?",10)
		If $Shutdown = 6 Then
			FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" Server Shutdown by User Input from ConanServerUtility Script")
			CloseServer()
		EndIf
		MsgBox(4096, "Thanks for using our Application", "Please visit us at https://gamercide.com",2)
	EndIf
	If $UseRemoteRestart = "yes" Then
		TCPShutdown()
	EndIf
	Exit
EndFunc

Func CloseServer()
	Local $PID = ProcessExists($ConanPID)
	ControlSend($ConanhWnd, "", "", "I" & @CR)
	ControlSend($ConanhWnd, "", "", "I" & @CR)
	ControlSend($ConanhWnd, "", "", "^C")
	WinWaitClose($ConanhWnd, "", 60)
	If $PID Then
		ProcessClose($PID)
    EndIf
	FileDelete($PIDFile)
	FileDelete($hWndFile)
EndFunc

Func GetRSS()
	Local $oXML = ObjCreate("Microsoft.XMLHTTP")
	$oXML.Open("GET", "http://steamcommunity.com/games/440900/rss/", 0)
	$oXML.Send

	$sFile = _TempFile(@ScriptDir, '~', '.xml')
	FileWrite($sFile, $oXML.responseText)
EndFunc

Func ParseRSS()
	$sXML = $sFile
	Local $oXML = ObjCreate("Microsoft.XMLDOM")
	$oXML.Load($sXML)
	Local $oNames = $oXML.selectNodes("//rss/channel/item/title")
	Local $aMyDate, $aMyTime
	_DateTimeSplit(_NowCalc(), $aMyDate, $aMyTime)
    Local $cDate = "PATCH "& StringFormat("%02d", $aMyDate[3]) &"."& StringFormat("%02d", $aMyDate[2]) &"."& StringFormat("%04d", $aMyDate[1])
	Local $cFile = @ScriptDir &"\ConanServerUtility_LastUpdate.txt"
	For $oName In $oNames

		If StringRegExp($oName.text,"(?i)"& $cDate &"(?i)") Then
				If FileRead($cFile) = $oName.text Then
					;ConsoleWrite("No New Update" & @CRLF)
					ExitLoop
				Else
					FileDelete($cFile)
					FileWrite($cFile,$oName.text)
					Local $PID = ProcessExists($ConanPID)
					If $PID Then
						FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" ["& $oName.text &"] Restart for Update Requested by ConanServerUtility Script")
						CloseServer()
					EndIf
					ExitLoop
				EndIf
		EndIf
	Next
EndFunc

Func CheckInterval()
	$mNextCheck = (@MIN + $UpdateInterval)
	If $mNextCheck >= 60 Then
		$mNextCheck = ($mNextCheck - 60)
	EndIf
	If $mNextCheck = @MIN Then
		$mNextCheck = ($mNextCheck - 1)
	EndIf
EndFunc

Func UpdateCheck()
	GetRSS()
	ParseRSS()
	FileDelete($sFile)
	CheckInterval()
EndFunc

Func _TCP_Server_ClientIP($hSocket)
   Local $pSocketAddress, $aReturn
   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")
   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))
   If @error Or $aReturn[0] <> 0 Then Return $hSocket
	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))
   If @error Then Return $hSocket
	  $pSocketAddress = 0
   Return $aReturn[0]
EndFunc ;==>_TCP_Server_ClientIP

If $UseSteamCMD = "yes" Then
	Local $sFileExists = FileExists($steamcmddir &"\steamcmd.exe")
	If $sFileExists = 0 Then
		MsgBox ( 0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at "& $steamcmddir)
		Exit
	EndIf
	Local $sManifestExists = FileExists($steamcmddir &"\steamapps\appmanifest_443030.acf")
		If $sManifestExists = 1 Then
			Local $manifestFound = MsgBox (4100, "Warning", "Install manifest found at "& $steamcmddir &"\steamapps\appmanifest_443030.acf"& @CRLF & @CRLF &"Suggest moving file to "& _
			$serverdir &"\steamapps\appmanifest_443030.acf before running SteamCMD"& @CRLF & @CRLF &"Would you like to Exit Now?",20)
			If $manifestFound = 6 Then
				Exit
			EndIf
		EndIf
Else
	Local $cFileExists = FileExists($serverdir &"\ConanSandboxServer.exe")
	If $cFileExists = 0 Then
		MsgBox ( 0x0, "Conan Server Not Found", "Could not find ConanSandboxServer.exe at "& $serverdir)
		Exit
	EndIf
Endif


If $UseRemoteRestart = "yes" Then
; Start The TCP Services
TCPStartup()
Local $MainSocket = TCPListen($g_IP, $g_Port, 100)
	If $MainSocket = -1 Then
		MsgBox ( 0x0, "TCP Error", "Could not bind to [" &  $g_IP & "] Is this the correct Server IP?")
		Exit
		EndIf
EndIf

If $CheckForUpdate = "yes" Then
	CheckInterval()
EndIf

While True
If $UseRemoteRestart = "yes" Then
Local $ConnectedSocket = TCPAccept($MainSocket)
If $ConnectedSocket >= 0 Then
$Count = 0
While $Count < 30
$RECV = TCPRecv($ConnectedSocket,512)
$PassCompare = StringCompare($RECV, $RestartCode, 1)
   If $PassCompare = 0 Then
	  Local $PID = ProcessExists($ConanPID) ; Will return the PID or 0 if the process isn't found.
	  If $PID Then
		 Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)
		 CloseServer()
		 Sleep (10000)
		 ExitLoop
	  EndIf
	  Else
	    Local $IP = _TCP_Server_ClientIP($ConnectedSocket)
		FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" Restart ATTEMPT by Remote Host: "& $IP &" WRONG PASSWORD: "& $RECV)
		ExitLoop
   EndIf
$Count += 1
Sleep (1000)
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
EndIf
EndIf


Local $PID = ProcessExists($ConanPID)
If $PID = 0 Then
	If $UseSteamCMD = "yes" Then
		If $validategame = "yes" Then
			RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 validate +quit")
		Else
			RunWait(""& $steamcmddir &"\steamcmd.exe +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir "& $serverdir &" +app_update 443030 +quit")
		EndIf
	EndIf
	If $CheckForUpdate = "yes" Then
		UpdateCheck()
	EndIf
	If $BindIP = "no" Then
		$ConanPID = Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?Port="& $GamePort &"?QueryPort="& $QueryPort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	Else
		$ConanPID = Run(""& $serverdir &"\ConanSandbox\Binaries\Win64\"& $Server_EXE &" ConanSandBox?MULTIHOME="& $g_IP &"?Port="& $GamePort &"?QueryPort="& $QueryPort &"?MaxPlayers="& $MaxPlayers &"?AdminPassword="& $AdminPass &"?listen -nosteamclient -game -server -log")
	EndIf
	$ConanhWnd = WinGetHandle(WinWait(""& $serverdir &"", "", 70))
	If $SteamFix = "yes" Then
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
		WinWait(""& $Server_EXE &" - Entry Point Not Found","",5)
		If WinExists(""& $Server_EXE &" - Entry Point Not Found") Then
			ControlSend(""& $Server_EXE &" - Entry Point Not Found", "", "", "{enter}")
		EndIf
	EndIf
	FileDelete($PIDFile)
	FileDelete($hWndFile)
	FileWrite($PIDFile,$ConanPID)
	FileWrite($hWndFile,String($ConanhWnd))
	FileSetAttrib($PIDFile,"+HT")
	FileSetAttrib($hWndFile,"+HT")
Else
   Local $MEM = ProcessGetStats($PID, 0)
   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_ExcessiveMemoryLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
        " --Peak Memory:"& $MEM[1])
	  Sleep (10000)
   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then
	  FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by ConanServerUtility Script")
	  CloseServer()
	  Sleep (10000)
   EndIf
EndIf

If ((@HOUR = $HotHour1 Or @HOUR = $HotHour2 Or @HOUR = $HotHour3 Or @HOUR = $HotHour4 Or @HOUR = $HotHour5 Or @HOUR = $HotHour6) And @MIN = $HotMin And $RestartDaily = "yes") Then
   Local $PID = ProcessExists($ConanPID)
	  If $PID Then
		 Local $MEM = ProcessGetStats($PID, 0)
		 FileWriteLine(@ScriptDir & "\ConanServerUtility_RestartLog.txt", @YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _
		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by ConanServerUtility Script")
		 CloseServer()
	  EndIf
   Sleep (10000)
EndIf

If @MIN = $mNextCheck And $CheckForUpdate = "yes" Then
	UpdateCheck()
	;Sleep(70000)
EndIf

Sleep (500)
WEnd

 

 

Link to comment
Share on other sites

could you add a section for server name. Every restart my server converts back to the default server name.

 

I never could make the server name work through the command line. Are you changing the name in the default INI? The one under Saved should not change after a restart.

Link to comment
Share on other sites

32 minutes ago, upperking said:

Maybe something like this showing server info at bottom of CMD?

https://gyazo.com/b8c14ea77ccd8f4d06bf3819f3e7f4e1

That's outside the scope of what this can do. It's mainly just automation. You want something like this:

 

http://www.jffgaming.com/resources/cat-conan-admin-tool.5/

Link to comment
Share on other sites

 

57 minutes ago, verser said:

im getting false flags from McAfee claiming this is a trojan.

 

It could be flagging it for any number of reasons. It simulates key presses, it opens a port if you have remote restart on, etc.

 

Best you you can do is report it as a false positive to them and add it to the ignore list. 

I never ran a virus check against it as I compiled it from source, but I see now there are some false flags. 

 

Virus Total Scan (4/57 detected it as a virus)

https://goo.gl/k3jpMV

The actual script is flagged as clean. If you don't trust it as an exe you can download AutoIT and compile as an a3x and run it that way. Or run the source directly. 

Link to comment
Share on other sites

V2.4 - No major changes except some internal cleanup. I was driving myself crazy versioning through flat files. This grew a bit larger that I expected. All source and downloads have been moved to GitHub.

Oh, I did compile 64bit binaries if anyone is interested in using them instead.

V2.4

[Latest Releases]

SOURCE ON GITHUB

Link to comment
Share on other sites

8 hours ago, Dateranoth said:

 

I never could make the server name work through the command line. Are you changing the name in the default INI? The one under Saved should not change after a restart.

Yes iv changed engine ini in saved. and also have tried changing default engine ini in the config folder. The engine ini server name line doesn't seem to effect my server at all. and the default engine ini reverts back to default every time the server starts up.

Link to comment
Share on other sites

18 minutes ago, MistDreamer said:

Yes iv changed engine ini in saved. and also have tried changing default engine ini in the config folder. The engine ini server name line doesn't seem to effect my server at all. and the default engine ini reverts back to default every time the server starts up.

And just so I'm clear. You are making changes to this file :

CONANSERVERDIR\ConanSandbox\Saved\Config\WindowsServer\Engine.ini

and adding this to the above file doesn't work?

[OnlineSubsystemSteam]
ServerName=YOURSERVERNAME

 

Link to comment
Share on other sites

Thanks @Murena. Much appreciated!

 

V2.4.1 Beta Release - Log Rotate

Rotate of the logs this utility makes btw. Does not rotate Conan Logs.

I have not tested this at all yet. So use at your own risk. Just wanted to get it out there for some brave soul to test for me if they are feeling nice!

https://github.com/Dateranoth/ConanExilesServerUtility/releases/tag/2.4.1-beta

 



In this release I have added the options to rotate the logs. It is currently only been compiled and not tested.

Be sure to move your existing INI, allow this one to create a new one, and update the new INI

New Options:
[Rotate X Number of Logs every X hours? yes/no]
logRotate=yes
logQuantity=10
logHoursBetweenRotate=24

There is no limit to the quanity of log files or time between rotation. When the highest number of logs is reached it will deleted the highest number. The logs will be in the format of ConanServerUtility.logXX

Finally, there was some modification to the way the check for updates is triggered. You can now enter a time from 5 minutes to however many minutes you wish.

 

Link to comment
Share on other sites

9 hours ago, Dateranoth said:

And just so I'm clear. You are making changes to this file :


CONANSERVERDIR\ConanSandbox\Saved\Config\WindowsServer\Engine.ini

and adding this to the above file doesn't work?


[OnlineSubsystemSteam]
ServerName=YOURSERVERNAME

 

yep, goes to default. iv tried skipping the validation. read only. only way i seem to name the server is with .bat.

Link to comment
Share on other sites

52 minutes ago, MistDreamer said:

yep, goes to default. iv tried skipping the validation. read only. only way i seem to name the server is with .bat.

Hmm. I'll try to make the server name pass through the Command line again. Maybe it will work since some of the last updates were pushed. 

Link to comment
Share on other sites

23 hours ago, MistDreamer said:

Yes iv changed engine ini in saved. and also have tried changing default engine ini in the config folder. The engine ini server name line doesn't seem to effect my server at all. and the default engine ini reverts back to default every time the server starts up.

 

V2.6 Release

By Request!

Set Server Name and Server Password using this utility.

After the script creates a new INI, copy your settings in and then update these two fields to the settings you want.

[Server Name]
ServerName=Gamercide.com Test Server
[Server Password]
ServerPass=

 

Link to comment
Share on other sites

23 hours ago, Dateranoth said:

 

V2.6 Release

By Request!

Set Server Name and Server Password using this utility.

After the script creates a new INI, copy your settings in and then update these two fields to the settings you want.


[Server Name]
ServerName=Gamercide.com Test Server
[Server Password]
ServerPass=

 

nice will have to test it out tonight

Link to comment
Share on other sites

V2.7 Release

This update is a major behind the scenes update. It adds considerably more logging, and changes the way the INI is handled. Now, it will check if there is missing variables and notify you if something is wrong with your INI. It will make a backup of your current INI, write all the variables that can be found from your current INI, and write the defaults of the variables it cannot find to a new INI.

You will also be notified of what server you are closing when you exit, including the PID.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...