-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate-arcdps.ps1
171 lines (148 loc) · 6.48 KB
/
update-arcdps.ps1
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 Jacob Keller. All rights reserved.
# vim: et:ts=4:sw=4
# Terminate on all errors...
$ErrorActionPreference = "Stop"
# Load the shared module
Import-Module -Force -DisableNameChecking (Join-Path -Path $PSScriptRoot -ChildPath l0g-101086.psm1)
Set-Logfile "update-arcdps.log"
# Relevant customizable configuration fields
# guildwars2_path
#
# Path to the Guild Wars 2 installation directory
# dll_backup_path
#
# Path to a folder to store backups of the previous version of files
# Load the configuration from the default file
$config = Load-Configuration (Get-Config-File)
if (-not $config) {
exit
}
if (-not (X-Test-Path $config.guildwars2_path)) {
Read-Host -Prompt "The Guild Wars 2 is not configured correctly. Press enter to exit"
exit
}
if (-not $config.dll_backup_path) {
Read-Host -Prompt "A .dll backup directory must be configured. Press enter to exit"
exit
} elseif (-not (X-Test-Path $config.dll_backup_path)) {
try {
New-Item -ItemType directory -Path $config.dll_backup_path
} catch {
Write-Exception $_
Read-Host -Prompt "Unable to create $($.config.dll_backup_path)"
exit
}
}
$files = @(
@{
dll = 'd3d9.dll'
backup = 'arc-d3d9.dll.back'
url = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll'
md5_url = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum'
},
@{
dll = 'd3d9_arcdps_extras.dll'
backup = 'extension-d3d9_arcdps_extras.dll.back'
url = 'https://www.deltaconnected.com/arcdps/x64/extras/d3d9_arcdps_extras.dll'
updatewith = 'd3d9.dll'
},
# @{
# dll = 'd3d9_arcdps_buildtemplates.dll'
# backup = 'extension-d3d9_arcdps_buildtemplates.dll.back'
# url = 'https://www.deltaconnected.com/arcdps/x64/buildtemplates/d3d9_arcdps_buildtemplates.dll'
# updatewith = 'd3d9.dll'
# },
@{
dll = 'd3d9_arcdps_mechanics.dll'
backup = 'extension-d3d9_arcdps_mechanics.dll.back'
url = 'http://martionlabs.com/wp-content/uploads/d3d9_arcdps_mechanics.dll'
md5_url = 'http://martionlabs.com/wp-content/uploads/d3d9_arcdps_mechanics.dll.md5sum'
},
@{
dll = 'd3d9_arcdps_table.dll'
backup = 'extension-d3d9_arcdps_table.dll.back'
url = 'http://martionlabs.com/wp-content/uploads/d3d9_arcdps_table.dll'
md5_url = 'http://martionlabs.com/wp-content/uploads/d3d9_arcdps_table.dll.md5sum'
}
)
Log-And-Write-Output "Checking for updates..."
# First, check to see what we should update in a loop. Because the ArcDs
# extras and buildtemplates plugins do not have their own MD5 sum file,
# this must be done up front before we loop to actually download the file
ForEach ($f in $files) {
$f.full_path = [io.path]::combine($config.guildwars2_path, $f.dll)
$f.bin_path = [io.path]::combine($config.guildwars2_path, "bin64", $f.dll)
$f.backup_path = [io.path]::combine($config.dll_backup_path, $f.backup)
if (-not (X-Test-Path $f.full_path)) {
Log-And-Write-Output "$($f.dll): not yet downloaded"
$f.update = $true
continue
}
# Some of the extensions don't have their own MD5 hash file
if (-not $f.md5_url) {
continue
}
$current_md5 = (Get-FileHash $f.full_path -Algorithm MD5).Hash
$web_md5 = ((Invoke-WebRequest -URI $f.md5_url -UseBasicParsing).toString().trim().toUpper() -split '\s+')[0]
Log-And-Write-Output "$($f.dll): Current MD5 Sum -- $current_md5"
Log-And-Write-Output "$($f.dll): Latest MD5 Sum -- $web_md5"
if ($web_md5.StartsWith($current_md5)) {
Log-And-Write-Output "$($f.dll): up to date"
} else {
Log-And-Write-Output "$($f.dll): needs to be updated"
$f.update = $true
ForEach ($child in $files.where{$_.updatewith -eq $f.dll}) {
Log-And-Write-Output "$($child.dll): needs to be updated"
$child.update = $true
}
}
}
ForEach ($f in $files.where{$_.update -eq $true}) {
Log-And-Write-Output "$($f.dll): downloading new copy"
# Make a back up of the current dll before overwriting it
if (X-Test-Path $f.full_path) {
if (X-Test-Path $f.backup_path) {
Remove-Item $f.backup_path
}
Move-Item $f.full_path $f.backup_path
}
# Remove the bin64 copy
if (X-Test-Path $f.bin_path) {
Remove-Item $f.bin_path
}
Invoke-WebRequest -Uri $f.url -UseBasicParsing -OutFile $f.full_path
Copy-Item $f.full_path $f.bin_path
}
# SIG # Begin signature block
# MIIFhQYJKoZIhvcNAQcCoIIFdjCCBXICAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU1rUls4H8jS1F83knkpivlzOq
# Qh2gggMYMIIDFDCCAfygAwIBAgIQLNFTiNzlwrtPtvlsLl9i3DANBgkqhkiG9w0B
# AQsFADAiMSAwHgYDVQQDDBdMMEctMTAxMDg2IENvZGUgU2lnbmluZzAeFw0xOTA1
# MTEwNjIxMjNaFw0yMDA1MTEwNjQxMjNaMCIxIDAeBgNVBAMMF0wwRy0xMDEwODYg
# Q29kZSBTaWduaW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz8yX
# +U/I8mljHGNNqj3Yu5m41ibtP7vXqhoFF16AWFMVI26sCFknvKO95h8ByCyyrSJy
# KouRR+bLwYg/a8ElqBA3r3nvnefWzFuj19lYoChautae6n1Yg80/V5XuY9tXjXRs
# LLA+rD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