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 if (!(Test-Path -Path .local\xbin))
23 New-Item -Path .local\xbin -ItemType Directory
25 Set-Content -Path .local\bin\webi.bat -Value "@echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\webi.ps1 %1`r`npopd"
26 if (!(Test-Path -Path .local\opt))
28 New-Item -Path .local\opt -ItemType Directory
30 # TODO windows version of mktemp -d
31 if (!(Test-Path -Path .local\tmp))
33 New-Item -Path .local\tmp -ItemType Directory
37 # TODO Test-Path variable:global:Env:WEBI_HOST ???
38 IF($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "")
40 $Env:WEBI_HOST = "https://webinstall.dev"
43 if (!(Test-Path -Path .local\bin\pathman.exe))
45 & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/packages/pathman/install.ps1" -o .\.local\tmp\pathman-setup.ps1
46 powershell .\.local\tmp\pathman-setup.ps1
47 # TODO del .\.local\tmp\pathman-setup.bat
50 # Run pathman to set up the folder
51 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
52 & "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
57 # Fetch <whatever>.ps1
59 $PKG_URL = "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,exe,tar"
60 echo "Downloading $PKG_URL"
61 # Invoke-WebRequest -UserAgent "Windows amd64" "$PKG_URL" -OutFile ".\.local\tmp\$exename.install.ps1"
62 & curl.exe -fsSL -A "$Env:WEBI_UA" "$PKG_URL" -o .\.local\tmp\$exename.install.ps1
65 powershell .\.local\tmp\$exename.install.ps1