Search the Community
Showing results for tags 'Utility'.
-
Installation Instructions: Place 7dServerUtility.exe in the same directory as 7DaysToDie.exe and run once. It will create a default INI file that you will need to modify for your server. Once you have modified the ini, restart the script and enjoy. If you want to use Putty to safely shutdown the server, then visit http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and download puttytel.exe . Place puttytel.exe in the same directory as 7dServerUtility.exe Remote Restart Instructions: Run 7dServerRemoteRestart.exe from anywhere. It will create a default INI file that you must modify. Modify the INI file and fill in the server IP and Restart Port. Optionally you can fill in the password field and it will save it so you don't have to type it each time. 7dServerUtility.au3 #include #include <Date.au3>#include <Process.au3>;User VariablesIf FileExists("7dServerUtility.ini") Then Local $GamePort = IniRead("7dServerUtility.ini", "GameServerPort", "GamePort", "25000") Local $ConfigFile = IniRead("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml") Local $UseRemoteRestart = IniRead("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no") Local $g_IP = IniRead("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1") Local $g_Port = IniRead("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539") Local $RestartCode = IniRead("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J") Local $RestartDaily= IniRead("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no") Local $HotHour = IniRead("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00") Local $HotMin = IniRead("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01") Local $ExMem = IniRead("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000") Local $ExMemRestart = IniRead("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no")Else IniWrite("7dServerUtility.ini", "GameServerPort", "GamePort", "25000") IniWrite("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml") IniWrite("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no") IniWrite("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1") IniWrite("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539") IniWrite("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J") IniWrite("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no") IniWrite("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00") IniWrite("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01") IniWrite("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000") IniWrite("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no") MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script") ExitEndIfOnAutoItExitRegister("CloseServer")Func CloseServer() If FileExists(@ScriptDir & "\puttytel.exe") Then $PuttyPort = $GamePort+3 Run(@ScriptDir & "\puttytel.exe -P "& $PuttyPort & " "& $g_IP) WinWait($g_IP &" - PuTTYtel","") Local $CrashCheck = WinWait("PuTTYtel Fatal Error","",5) If $CrashCheck = 0 Then ControlSend($g_IP &" - PuTTYtel", "", "", "{enter}") ControlSend($g_IP &" - PuTTYtel", "", "", "shutdown{enter}") WinWait("PuTTYtel Fatal Error","",10) Local $PID = ProcessExists("puttytel.exe") If $PID Then ProcessClose($PID) EndIf Else Local $PID = ProcessExists("puttytel.exe") Local $PID2 = ProcessExists("7DaysToDie.exe") If $PID Then ProcessClose($PID) EndIf If $PID2 Then ProcessClose($PID2) EndIf EndIf Else Local $PID = ProcessExists("7DaysToDie.exe") If $PID Then ProcessClose($PID) EndIf EndIfEndFuncFunc _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_ClientIPIf $UseRemoteRestart = "yes" Then; Start The TCP ServicesTCPStartup()Local $MainSocket = TCPListen($g_IP, $g_Port, 100)If $MainSocket = -1 Then ExitEndIfwhile True if WinExists("Oops!") Then ControlSend("Oops!", "", "", "{enter}") Sleep (10000) EndIfIf $UseRemoteRestart = "yes" ThenLocal $ConnectedSocket = TCPAccept($MainSocket)If $ConnectedSocket >= 0 Then;TrayTip("Connected","Someone connected to server.",3)$Count = 0While $Count < 30$RECV = TCPRecv($ConnectedSocket,512) If $RECV = $RestartCode Then Local $PID = ProcessExists("7DaysToDie.exe") ; Will return the PID or 0 if the process isn't found. If $PID Then $IP = _TCP_Server_ClientIP($ConnectedSocket) Local $MEM = ProcessGetStats($PID, 0) FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP) ;ProcessClose($PID) CloseServer() Sleep (10000) ExitLoop EndIf EndIf$Count += 1Sleep (1000)WEndIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)EndIfEndIfLocal $PID = ProcessExists("7DaysToDie.exe")If $PID = 0 Then Run(@ScriptDir & "\7DaysToDie.exe -quit -batchmode -nographics -configfile="& $ConfigFile &" -dedicated") Sleep (70000)Else Local $MEM = ProcessGetStats($PID, 0) If $MEM[0] > $ExMem And $ExMemRestart = "no" Then FileWriteLine(@ScriptDir & "\7dServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1]) Sleep (10000) ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by 7dServerUtility Script") ;ProcessClose($PID) CloseServer() Sleep (10000) EndIfEndIf If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then Local $PID = ProcessExists("7DaysToDie.exe") If $PID Then Local $MEM = ProcessGetStats($PID, 0) FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by 7dServerUtility Script") ;ProcessClose($PID) CloseServer() EndIf Sleep (10000) EndIfSleep (500)WEnd 7dServerRemoteRestart.au3 ; Start The TCP Services ;============================================== TCPStartup() ; Set Some reusable info ;-------------------------- Local $ConnectedSocket, $szDataIf FileExists("7dServerRemoteRestart.ini") Then Local $szIPADDRESS = IniRead("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1") Local $nPORT = IniRead("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539") Local $RPassword = IniRead("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")Else IniWrite("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1") IniWrite("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539") IniWrite("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "") MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script") ExitEndIf ; Initialize a variable to represent a connection ;============================================== $ConnectedSocket = -1 ;Attempt to connect to SERVER at its IP and PORT 57539 ;======================================================= $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) ; If there is an error... show it If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) ; If there is no error loop an inputbox for data ; to send to the SERVER. Else ;Loop forever asking for data to send to the SERVER While 1 ; InputBox for data to transmit $szData = InputBox("Reset The 7 Days to Die Server", @LF & @LF & "Enter the code to Reset The 7 Days to Die Server:",$RPassword) ; If they cancel the InputBox or leave it blank we exit our forever loop If @error Or $szData = "" Then ExitLoop ; We should have data in $szData... lets attempt to send it through our connected socket. ; convert AutoIt native UTF-16 to UTF-8 TCPSend($ConnectedSocket, StringToBinary($szData, 4)) ExitLoop ; If the send failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop WEnd EndIfIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)TCPShutdown()
- 15 comments
-
- 7 Days to Die
- PC
-
(and 2 more)
Tagged with:
-
I modified my Cube World Server Utility to work with 7 Days to Die. I also added a customizable ini file. NOTE! If you do not use the PuttyTel client to restart all restarts are hard restarts. The server process is closed, and it is closed when you exit the script. I have tested this, and it doesn't seem to be affecting save files, but you have been warned. Features: Optional Daily RestartsKeep Server Alive. Restart on CrashLog Excessive Memory UseOption to Restart on Excessive Memory UseOption to Remotely Restart ServerLogs restart request, current memory being used, and if the utility requested or a certain IPSafely shutdown the server through telnet via puttytel.exe and save server dayThe remote restart utility is a separate program. It allows you to connect and remotely restart a server.You can download the 7dServerUtility and 7dServerRemoteRestart compiled exe's HERE. (VirusScan) You can download the 7dServerUtility and 7dServerRemoteRestart AutoIT Source HERE. A special thanks to Nightmarefrom the 7 days to die forum for the telnet info! Installation Instructions: Place 7dServerUtility.exe in the same directory as 7DaysToDie.exe and run once. It will create a default INI file that you will need to modify for your server. Once you have modified the ini, restart the script and enjoy. If you want to use Putty to safely shutdown the server, then visit http://www.chiark.gr...y/download.html and download puttytel.exe . Place puttytel.exe in the same directory as 7dServerUtility.exe Remote Restart Instructions: Run 7dServerRemoteRestart.exe from anywhere. It will create a default INI file that you must modify. Modify the INI file and fill in the server IP and Restart Port. Optionally you can fill in the password field and it will save it so you don't have to type it each time. 7dServerUtility.au3 #include #include <Date.au3>#include <Process.au3>;User VariablesIf FileExists("7dServerUtility.ini") Then Local $GamePort = IniRead("7dServerUtility.ini", "GameServerPort", "GamePort", "25000") Local $ConfigFile = IniRead("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml") Local $UseRemoteRestart = IniRead("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no") Local $g_IP = IniRead("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1") Local $g_Port = IniRead("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539") Local $RestartCode = IniRead("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J") Local $RestartDaily= IniRead("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no") Local $HotHour = IniRead("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00") Local $HotMin = IniRead("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01") Local $ExMem = IniRead("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000") Local $ExMemRestart = IniRead("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no")Else IniWrite("7dServerUtility.ini", "GameServerPort", "GamePort", "25000") IniWrite("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml") IniWrite("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no") IniWrite("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1") IniWrite("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539") IniWrite("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J") IniWrite("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no") IniWrite("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00") IniWrite("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01") IniWrite("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000") IniWrite("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no") MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script") ExitEndIfOnAutoItExitRegister("CloseServer")Func CloseServer() If FileExists(@ScriptDir & "\puttytel.exe") Then $PuttyPort = $GamePort+3 Run(@ScriptDir & "\puttytel.exe -P "& $PuttyPort & " "& $g_IP) WinWait($g_IP &" - PuTTYtel","") Local $CrashCheck = WinWait("PuTTYtel Fatal Error","",5) If $CrashCheck = 0 Then ControlSend($g_IP &" - PuTTYtel", "", "", "{enter}") ControlSend($g_IP &" - PuTTYtel", "", "", "shutdown{enter}") WinWait("PuTTYtel Fatal Error","",10) Local $PID = ProcessExists("puttytel.exe") If $PID Then ProcessClose($PID) EndIf Else Local $PID = ProcessExists("puttytel.exe") Local $PID2 = ProcessExists("7DaysToDie.exe") If $PID Then ProcessClose($PID) EndIf If $PID2 Then ProcessClose($PID2) EndIf EndIf Else Local $PID = ProcessExists("7DaysToDie.exe") If $PID Then ProcessClose($PID) EndIf EndIfEndFuncFunc _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_ClientIPIf $UseRemoteRestart = "yes" Then; Start The TCP ServicesTCPStartup()Local $MainSocket = TCPListen($g_IP, $g_Port, 100)If $MainSocket = -1 Then ExitEndIfwhile True if WinExists("Oops!") Then ControlSend("Oops!", "", "", "{enter}") Sleep (10000) EndIfIf $UseRemoteRestart = "yes" ThenLocal $ConnectedSocket = TCPAccept($MainSocket)If $ConnectedSocket >= 0 Then;TrayTip("Connected","Someone connected to server.",3)$Count = 0While $Count < 30$RECV = TCPRecv($ConnectedSocket,512) If $RECV = $RestartCode Then Local $PID = ProcessExists("7DaysToDie.exe") ; Will return the PID or 0 if the process isn't found. If $PID Then $IP = _TCP_Server_ClientIP($ConnectedSocket) Local $MEM = ProcessGetStats($PID, 0) FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP) ;ProcessClose($PID) CloseServer() Sleep (10000) ExitLoop EndIf EndIf$Count += 1Sleep (1000)WEndIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)EndIfEndIfLocal $PID = ProcessExists("7DaysToDie.exe")If $PID = 0 Then Run(@ScriptDir & "\7DaysToDie.exe -quit -batchmode -nographics -configfile="& $ConfigFile &" -dedicated") Sleep (70000)Else Local $MEM = ProcessGetStats($PID, 0) If $MEM[0] > $ExMem And $ExMemRestart = "no" Then FileWriteLine(@ScriptDir & "\7dServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1]) Sleep (10000) ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by 7dServerUtility Script") ;ProcessClose($PID) CloseServer() Sleep (10000) EndIfEndIf If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then Local $PID = ProcessExists("7DaysToDie.exe") If $PID Then Local $MEM = ProcessGetStats($PID, 0) FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _ " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by 7dServerUtility Script") ;ProcessClose($PID) CloseServer() EndIf Sleep (10000) EndIfSleep (500)WEnd 7dServerRemoteRestart.au3 ; Start The TCP Services ;============================================== TCPStartup() ; Set Some reusable info ;-------------------------- Local $ConnectedSocket, $szDataIf FileExists("7dServerRemoteRestart.ini") Then Local $szIPADDRESS = IniRead("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1") Local $nPORT = IniRead("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539") Local $RPassword = IniRead("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")Else IniWrite("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1") IniWrite("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539") IniWrite("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "") MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script") ExitEndIf ; Initialize a variable to represent a connection ;============================================== $ConnectedSocket = -1 ;Attempt to connect to SERVER at its IP and PORT 57539 ;======================================================= $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) ; If there is an error... show it If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) ; If there is no error loop an inputbox for data ; to send to the SERVER. Else ;Loop forever asking for data to send to the SERVER While 1 ; InputBox for data to transmit $szData = InputBox("Reset The 7 Days to Die Server", @LF & @LF & "Enter the code to Reset The 7 Days to Die Server:",$RPassword) ; If they cancel the InputBox or leave it blank we exit our forever loop If @error Or $szData = "" Then ExitLoop ; We should have data in $szData... lets attempt to send it through our connected socket. ; convert AutoIt native UTF-16 to UTF-8 TCPSend($ConnectedSocket, StringToBinary($szData, 4)) ExitLoop ; If the send failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop WEnd EndIfIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)TCPShutdown()Click here to view the article
- 15 replies
-
- 7 Days to Die
- PC
-
(and 2 more)
Tagged with: