This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Installer.ps1
52 lines (39 loc) · 1.91 KB
/
Installer.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
Write-Host "Installing Passcore"
Write-Host "Creating Directory"
$directory = "C:\passcore"
New-Item -ItemType directory -Path $directory
Set-Location $directory
# Determining latest release
Write-Host "Determining latest release"
$releasesUrl = "https://api.github.com/repos/unosquare/passcore/releases"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releases = Invoke-WebRequest $releasesUrl -UseBasicParsing
$releasesJson = ($releases.Content | ConvertFrom-Json)[0]
$zipName = "passcore.zip"
$zipUrl = $releasesJson.assets.browser_download_url | where-object {$_ -NotLike "*mac*" -and $_ -NotLike "*linux*"}
$zipPath = "$($directory)\$($zipName)"
# Downloading
Write-Host "Downloading $($zipName)"
Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath -UseBasicParsing
# Unzipping
Write-Host "Unzipping"
Expand-Archive $zipPath -dest $directory -force
Remove-Item $zipPath
# Checkin for Net Core Host
$netCoreHost = Get-wmiobject -class win32_product | Where-Object {$_.Name -match "Microsoft .NET Core Host - 3.0" }
if([string]::IsNullOrEmpty($netCoreHost)) {
Write-Host "Please install the hosting bundle and then restart the installation"
Start-Process "https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-3.0.0-windows-hosting-bundle-installer"
exit 1
}
# IIS setup script
# Comment or delete the follow lines if you are making a custom installation and setup
Write-Host "IIS setup running"
$iisSetup = (new-object net.webclient).DownloadString('https://raw.githubusercontent.com/unosquare/passcore/master/IISSetup.ps1')
Invoke-Command -ScriptBlock ([scriptblock]::Create($iisSetup)) -ArgumentList $directory
Write-Host "Once you finish configuring appsettings.json, passcore will restart"
Start-Process notepad .\appsettings.json -NoNewWindow -Wait
Write-Host "Restarting passcore"
Import-Module WebAdministration
Stop-WebSite 'passcore'
Start-WebSite 'passcore'