Skip to content

Commit

Permalink
Use Github API to find Oxide URL
Browse files Browse the repository at this point in the history
Updated script to use the api to find the full path of the url. I was previously only using the version, but file name changes could cause problems.
  • Loading branch information
Dateranoth committed Nov 18, 2017
1 parent ec47525 commit cb6b046
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/RustServerUtility/RustServerUtility.au3
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\resources\favicon.ico
#AutoIt3Wrapper_Outfile=..\..\build\RustServerUtility_x86_v1.1.2.exe
#AutoIt3Wrapper_Outfile_x64=..\..\build\RustServerUtility_x64_v1.1.2.exe
#AutoIt3Wrapper_Outfile=..\..\build\RustServerUtility_x86_v1.2.0.exe
#AutoIt3Wrapper_Outfile_x64=..\..\build\RustServerUtility_x64_v1.2.0.exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Comment=By Dateranoth - November 16, 2017
#AutoIt3Wrapper_Res_Comment=By Dateranoth - November 17, 2017
#AutoIt3Wrapper_Res_Description=Utility for Running Rust Server
#AutoIt3Wrapper_Res_Fileversion=1.1.2.0
#AutoIt3Wrapper_Res_Fileversion=1.2.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Dateranoth @ https://gamercide.com
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Expand Down Expand Up @@ -779,7 +779,7 @@ EndFunc ;==>UpdateCheck

#Region ;**** Checking and Updating Oxide ****
Func GetLatestOxideVersion($sGameDir)
Local $aReturn[2] = [False, ""]
Local $aReturn[3] = [False, "", ""]
Local $sTempDir = $sGameDir & "\tmp\"
If Not FileExists($sTempDir) Then
DirCreate($sGameDir & "\tmp")
Expand All @@ -792,12 +792,15 @@ Func GetLatestOxideVersion($sGameDir)
Else
Local $sFileRead = FileRead($hFileOpen)
Local $aAppInfo = StringSplit($sFileRead, '","target_commitish"', 1)
If UBound($aAppInfo) >= 3 Then
Local $aAppInfo2 = StringSplit($sFileRead, '"}],"tarball_url":"', 1)
If UBound($aAppInfo) >= 3 And UBound($aAppInfo2) >= 3 Then
$aAppInfo = StringSplit($aAppInfo[1], '"tag_name":"', 1)
$aAppInfo2 = StringSplit($aAppInfo2[1], '"browser_download_url":"', 1)
EndIf
If UBound($aAppInfo) >= 3 Then
If UBound($aAppInfo) >= 3 And UBound($aAppInfo2) >= 3 Then
$aReturn[0] = True
$aReturn[1] = $aAppInfo[2]
$aReturn[1] = $aAppInfo2[2]
EndIf
FileClose($hFileOpen)
If FileExists($sFilePath) Then
Expand All @@ -808,7 +811,6 @@ Func GetLatestOxideVersion($sGameDir)
Return $aReturn
EndFunc ;==>GetLatestOxideVersion


Func GetInstalledOxideVersion($sGameDir)
Local $aReturn[2] = [False, ""]
Local Const $sFileDir = $sGameDir & "\oxide\logs\"
Expand Down Expand Up @@ -890,25 +892,25 @@ Func UpdateOxideCheck()
ElseIf Not $aLatestVersion[0] Then
FileWriteLine($g_c_sLogFile, _NowCalc() & " [" & $g_sServerHostName & " (PID: " & $g_sRustPID & ")] Something went wrong retrieving Oxide Latest Version")
EndIf
Local $aReturn[2] = [$bUpdateRequired, $aLatestVersion[1]]
Local $aReturn[3] = [$bUpdateRequired, $aLatestVersion[1], $aLatestVersion[2]]
Return $aReturn
EndFunc ;==>UpdateOxideCheck

Func DownloadOxide($sVersion = "latest")
Func DownloadOxide($sVersion, $sURL)
Local Const $g_c_sTempDir = $g_sServerDir & "\tmp\"
If FileExists($g_c_sTempDir) Then
DirRemove($g_c_sTempDir, 1)
EndIf
DirCreate($g_sServerDir & "\tmp")
InetGet("https://github.com/OxideMod/Oxide.Rust/releases/download/" & $sVersion & "/Oxide-Rust.zip", $g_c_sTempDir & "Oxide-Rust.zip", 0)
InetGet($sURL, $g_c_sTempDir & "Oxide-Rust.zip", 0)
Local Const $sFilePath = $g_c_sTempDir & "Oxide-Rust.zip"
If FileExists($sFilePath) Then
Local $hExtractFile = _ExtractZip($g_c_sTempDir & "Oxide-Rust.zip", "", "RustDedicated_Data", $g_c_sTempDir)
If $hExtractFile Then
FileWriteLine($g_c_sLogFile, _NowCalc() & " Latest Oxide Version " & $sVersion & " Downloaded.")
FileWriteLine($g_c_sLogFile, _NowCalc() & " Downloaded Oxide from " & $sURL)
If FileExists($g_c_sTempDir & "RustDedicated_Data") Then
DirCopy($g_c_sTempDir & "RustDedicated_Data", $g_sServerDir & "\RustDedicated_Data", 1)
FileWriteLine($g_c_sLogFile, _NowCalc() & " Oxide Updated")
FileWriteLine($g_c_sLogFile, _NowCalc() & " Oxide Updated to Version " & $sVersion)
Else
FileWriteLine($g_c_sLogFile, _NowCalc() & " Something went wrong Moving Oxide Folder.")
EndIf
Expand All @@ -917,7 +919,7 @@ Func DownloadOxide($sVersion = "latest")
EndIf
DirRemove($g_c_sTempDir, 1)
Else
FileWriteLine($g_c_sLogFile, _NowCalc() & " Something Went Wrong Downloading Oxide.")
FileWriteLine($g_c_sLogFile, _NowCalc() & " Something Went Wrong Downloading Oxide from " & $sURL)
EndIf
EndFunc ;==>DownloadOxide
#EndRegion ;**** Checking and Updating Oxide ****
Expand Down Expand Up @@ -972,7 +974,7 @@ EndFunc ;==>_TCP_Server_ClientIP

#Region ;**** Startup Checks. Initial Log, Read INI, Check for Correct Paths, Check Remote Restart is bound to port. ****
OnAutoItExitRegister("Gamercide")
FileWriteLine($g_c_sLogFile, _NowCalc() & " RustServerUtility Script v1.1.2 Started")
FileWriteLine($g_c_sLogFile, _NowCalc() & " RustServerUtility Script v1.2.0 Started")
ReadUini()

If $g_sUseSteamCMD = "yes" Then
Expand Down Expand Up @@ -1078,7 +1080,7 @@ While True ;**** Loop Until Closed ****
If $g_sUseOxide = "yes" Then
Local $aOxideUpdateCheck = UpdateOxideCheck()
If $aOxideUpdateCheck[0] Then
DownloadOxide($aOxideUpdateCheck[1])
DownloadOxide($aOxideUpdateCheck[1], $aOxideUpdateCheck[2])
EndIf
EndIf
If $g_sMonthlyWipes = "yes" Then
Expand Down

0 comments on commit cb6b046

Please sign in to comment.