-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
executable file
·83 lines (66 loc) · 1.9 KB
/
install.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
#!/usr/bin/env pwsh
# inherit from https://deno.land/x/[email protected]/install.ps1
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
# required:
# 1. $repo or $r
# 2. $version or $v
# 2. $exe or $e
$ErrorActionPreference = 'Stop'
$githubUrl = if ($github) {
"${github}"
} elseif ($g) {
"${g}"
}else {
"https://github.com"
}
$owner = "MapoMagpie"
$repoName = "rimedm"
$exeName = "rimedm"
if ([Environment]::Is64BitProcess) {
$arch = "x86_64"
} else {
$arch = "i386"
}
$BinDir = "$Home\Appdata\Local\Programs\rimedm"
$downloadedTagGz = "$BinDir\${exeName}.zip"
$downloadedExe = "$BinDir\${exeName}.exe"
$Target = "Windows_$arch"
# GitHub requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ResourceUri = if (!$version) {
"${githubUrl}/${owner}/${repoName}/releases/latest/download/${exeName}_${Target}.zip"
} else {
"${githubUrl}/${owner}/${repoName}/releases/download/${Version}/${exeName}_${Target}.zip"
}
if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
Invoke-WebRequest $ResourceUri -OutFile $downloadedTagGz -UseBasicParsing -ErrorAction Stop
function Check-Command {
param($Command)
$found = $false
try
{
$Command | Out-Null
$found = $true
}
catch [System.Management.Automation.CommandNotFoundException]
{
$found = $false
anakan
}
$found
}
function Unzip($zipFile, $dest) {
Expand-Archive -Force -Path $zipFile -DestinationPath $dest
}
Unzip $downloadedTagGz $BinDir
Remove-Item $downloadedTagGz
$User = [EnvironmentVariableTarget]::User
$Path = [Environment]::GetEnvironmentVariable('Path', $User)
if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) {
[Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User)
$Env:Path += ";$BinDir"
}
Write-Output "${exeName} was installed successfully to $downloadedExe"
Write-Output "Run '${exeName} --h' to get started"