-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate.PS1
More file actions
91 lines (68 loc) · 2.65 KB
/
Update.PS1
File metadata and controls
91 lines (68 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
param(
[Parameter(Mandatory = $false)]
[ValidateSet("Windows", "Linux")]
[string]$OS = "Linux",
[Parameter(Mandatory = $false)]
[bool]$Clean = $false,
[Parameter(Mandatory = $false)]
[bool]$Staging = $false
)
$FolderDependencies = Join-Path '.' 'dependencies'
if ($Clean -and (Test-Path $FolderDependencies)) {
Remove-Item -Path $FolderDependencies -Recurse -Force
}
New-Item -Name $FolderDependencies -ItemType Directory -Force
$FolderServer = Join-Path $FolderDependencies 'server' $OS
if ($Clean -and (Test-Path $FolderServer)) {
Remove-Item -Path $FolderServer -Recurse -Force
}
New-Item -Name $FolderServer -ItemType Directory -Force
$FolderTools = Join-Path '.' 'tools'
if ($Clean -and (Test-Path $FolderTools)) {
Remove-Item -Path $FolderTools -Recurse -Force
}
New-Item -Name $FolderTools -ItemType Directory -Force
$FolderDepotDownloader = Join-Path $FolderTools 'DepotDownloader'
New-Item -Name $FolderDepotDownloader -ItemType Directory -Force
$DepotDownloader = Join-Path $FolderDepotDownloader 'DepotDownloader.dll'
if ($Clean -or -not (Test-Path $DepotDownloader)) {
$LinkDepotDownloader = 'https://github.com/SteamRE/DepotDownloader/releases/latest/download/DepotDownloader-framework.zip'
$ArchiveDepotDownloader = Join-Path $FolderDepotDownloader 'DepotDownloader.zip'
Invoke-WebRequest $LinkDepotDownloader -OutFile $ArchiveDepotDownloader
Expand-Archive -Path $ArchiveDepotDownloader -DestinationPath $FolderDepotDownloader -Force
Remove-Item -Path $ArchiveDepotDownloader -Force
}
Start-Process -FilePath 'dotnet' -ArgumentList @(
$DepotDownloader
'-app 258550'
"-os $($OS.ToLower())"
$Staging ? '-branch staging' : ''
"-dir $FolderServer"
'-filelist RustDependencies.txt'
'-validate'
) -NoNewWindow -Wait
switch ($OS) {
'Windows' {
if ($Staging) {
$LinkOxide = 'https://downloads.oxidemod.com/artifacts/Oxide.Rust/staging/Oxide.Rust.zip'
}
else {
$LinkOxide = 'https://github.com/OxideMod/Oxide.Rust/releases/latest/download/Oxide.Rust.zip'
}
}
'Linux' {
if ($Staging) {
$LinkOxide = 'https://downloads.oxidemod.com/artifacts/Oxide.Rust/staging/Oxide.Rust-linux.zip'
}
else {
$LinkOxide = 'https://github.com/OxideMod/Oxide.Rust/releases/latest/download/Oxide.Rust-linux.zip'
}
}
default {
throw 'Unable to determine OS'
}
}
$ArchiveOxide = Join-Path $FolderServer 'Oxide.zip'
Invoke-WebRequest $LinkOxide -OutFile $ArchiveOxide
Expand-Archive -Path $ArchiveOxide -DestinationPath $FolderServer -Force
Remove-Item -Path $ArchiveOxide -Force