-
Notifications
You must be signed in to change notification settings - Fork 108
/
update_iran_dat.ps1
32 lines (30 loc) · 1011 Bytes
/
update_iran_dat.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
Param(
$current_file
)
$url = "https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat"
if ($current_file -eq "") {
"Usage: update_iran.dat.ps1 </path/to/iran.dat>"
Exit
}
if (Test-Path $current_file -PathType Leaf) {
$tmpfile = New-TemporaryFile
Start-BitsTransfer -Source "$url.sha256" -Destination $tmpfile
$new_checksum = (Get-Content -Path $tmpfile).Substring(0, 64).ToUpper()
if ($new_checksum -eq (Get-FileHash -Path $current_file).Hash) {
"Domains file is already up to date."
}
else {
Start-BitsTransfer -Source $url -Destination $tmpfile
if ($new_checksum -eq (Get-FileHash -Path $tmpfile).Hash) {
Copy-Item -Path $tmpfile -Destination $current_file
"Domains file updated successfully."
}
else {
"Domains file is invalid."
}
}
}
else {
Start-BitsTransfer -Source $url -Destination $current_file
"Domains file downloaded successfully."
}