powershell updates
[webi-installers/.git] / _webi / bootstrap.ps1
1 #!/usr/bin/env pwsh
2
3 # If a command returns an error, halt the script.
4 $ErrorActionPreference = 'Stop'
5
6 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
7 $ProgressPreference = 'SilentlyContinue'
8
9 # Switch to userprofile
10 pushd $Env:USERPROFILE
11
12 # Make paths if needed
13 if (!(Test-Path -Path .local\bin))
14 {
15     New-Item -Path .local\bin -ItemType Directory
16 }
17
18 # {{ baseurl }}
19 # {{ version }}
20
21 # Enter path
22 pushd .local\bin
23
24 # TODO SetStrictMode
25 # TODO Test-Path variable:global:Env:WEBI_HOST ???
26 IF($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "")
27 {
28     $Env:WEBI_HOST = "https://webinstall.dev"
29 }
30
31 # Fetch webi.bat
32 echo "$Env:WEBI_HOST/packages/_webi/webi.ps1"
33 curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi.ps1.bat" -o webi.bat
34 curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi.ps1" -o webi.ps1
35
36 popd
37
38 # Run webi.ps1
39 #TODO Set-ExecutionPolicy -ExecutionPolicy Bypass
40 Invoke-Expression "powershell -ExecutionPolicy Bypass .\.local\bin\webi.ps1 {{ exename }}"
41
42 # Run pathman to set up the folder
43 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\.bin"
44 & "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\.bin
45
46 # Done
47 popd