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\opt))
23 New-Item -Path .local\opt -ItemType Directory
25 # TODO windows version of mktemp -d
26 if (!(Test-Path -Path .local\tmp))
28 New-Item -Path .local\tmp -ItemType Directory
32 # TODO Test-Path variable:global:Env:WEBI_HOST ???
35 $Env:WEBI_HOST = "https://webinstall.dev"
38 if (!(Test-Path -Path .local\bin\pathman.exe))
40 & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/packages/pathman/install.ps1" -o .\.local\tmp\pathman-setup.ps1
41 powershell .\.local\tmp\pathman-setup.ps1
42 # TODO del .\.local\tmp\pathman-setup.bat
48 # Fetch <whatever>.ps1
49 echo "$Env:WEBI_HOST/packages/$exename/install.ps1"
50 echo "$exename.install.ps1"
53 # Invoke-WebRequest -UserAgent "Windows amd64" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -OutFile ".\.local\tmp\$exename.install.ps1"
54 & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -o .\.local\tmp\$exename.install.ps1
57 powershell .\.local\tmp\$exename.install.ps1