3 # If a command returns an error, halt the script.
4 $ErrorActionPreference = 'Stop'
6 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
7 $ProgressPreference = 'SilentlyContinue'
10 $Env:WEBI_UA = 'Windows/10 amd64'
13 # Switch to userprofile
14 pushd $Env:USERPROFILE
16 # Make paths if needed
17 if (!(Test-Path -Path .local\bin))
19 New-Item -Path .local\bin -ItemType Directory
21 Set-Content -Path .local\bin\webi.bat -Value "echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\webi.ps1 %1`r`npopd"
22 if (!(Test-Path -Path .local\opt))
24 New-Item -Path .local\opt -ItemType Directory
26 # TODO windows version of mktemp -d
27 if (!(Test-Path -Path .local\tmp))
29 New-Item -Path .local\tmp -ItemType Directory
33 # TODO Test-Path variable:global:Env:WEBI_HOST ???
34 IF($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "")
36 $Env:WEBI_HOST = "https://webinstall.dev"
39 if (!(Test-Path -Path .local\bin\pathman.exe))
41 & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/packages/pathman/install.ps1" -o .\.local\tmp\pathman-setup.ps1
42 powershell .\.local\tmp\pathman-setup.ps1
43 # TODO del .\.local\tmp\pathman-setup.bat
46 # Run pathman to set up the folder
47 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
48 & "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\bin
53 # Fetch <whatever>.ps1
55 # Invoke-WebRequest -UserAgent "Windows amd64" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -OutFile ".\.local\tmp\$exename.install.ps1"
56 echo "Downloading $Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar"
57 & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -o .\.local\tmp\$exename.install.ps1
60 powershell .\.local\tmp\$exename.install.ps1