From 2640e73b0fc34b63320482c8ab6c62d3fc881486 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 30 Jun 2020 21:03:49 +0000 Subject: [PATCH] windows fixes --- _webi/bootstrap.ps1 | 52 +++++----------------------------------- _webi/webi.ps1 | 9 ++++--- ssh-utils/ssh-pubkey.ps1 | 2 +- 3 files changed, 13 insertions(+), 50 deletions(-) diff --git a/_webi/bootstrap.ps1 b/_webi/bootstrap.ps1 index 168c457..202f87d 100644 --- a/_webi/bootstrap.ps1 +++ b/_webi/bootstrap.ps1 @@ -1,47 +1,7 @@ -#!/usr/bin/env pwsh - -# If a command returns an error, halt the script. -$ErrorActionPreference = 'Stop' - -# Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow -$ProgressPreference = 'SilentlyContinue' - -# Switch to userprofile -pushd $Env:USERPROFILE - -# Make paths if needed -if (!(Test-Path -Path .local\bin)) -{ - New-Item -Path .local\bin -ItemType Directory -} - -# {{ baseurl }} -# {{ version }} - -# Enter path -pushd .local\bin - -# TODO SetStrictMode -# TODO Test-Path variable:global:Env:WEBI_HOST ??? -IF($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") -{ - $Env:WEBI_HOST = "https://webinstall.dev" -} - -# Fetch webi.bat -echo "$Env:WEBI_HOST/packages/_webi/webi.ps1" -curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi.ps1.bat" -o webi.bat -curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi.ps1" -o webi.ps1 - -popd - -# Run webi.ps1 -#TODO Set-ExecutionPolicy -ExecutionPolicy Bypass -Invoke-Expression "powershell -ExecutionPolicy Bypass .\.local\bin\webi.ps1 {{ exename }}" - -# Run pathman to set up the folder -#& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\.bin" -& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\.bin - -# Done +# Download the latest webi, then install {{ exename }} +IF (!(Test-Path -Path .local\bin)) { New-Item -Path .local\bin -ItemType Directory } +IF ($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" } +curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi.ps1" -o "$Env:USERPROFILE\.local\bin\webi.ps1" +pushd "$Env:USERPROFILE" +& powershell -ExecutionPolicy Bypass ".local\bin\webi.ps1" "{{ exename }}" popd diff --git a/_webi/webi.ps1 b/_webi/webi.ps1 index 1a961fc..948b1c2 100644 --- a/_webi/webi.ps1 +++ b/_webi/webi.ps1 @@ -18,6 +18,7 @@ if (!(Test-Path -Path .local\bin)) { New-Item -Path .local\bin -ItemType Directory } +Set-Content -Path .local\bin\webi.bat -Value "echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\webi.ps1 %1`r`npopd" if (!(Test-Path -Path .local\opt)) { New-Item -Path .local\opt -ItemType Directory @@ -42,15 +43,17 @@ if (!(Test-Path -Path .local\bin\pathman.exe)) # TODO del .\.local\tmp\pathman-setup.bat } +# Run pathman to set up the folder +#& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\.bin" +& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\.bin + # {{ baseurl }} # {{ version }} # Fetch .ps1 -echo "$Env:WEBI_HOST/packages/$exename/install.ps1" -echo "$exename.install.ps1" - # TODO detect formats # Invoke-WebRequest -UserAgent "Windows amd64" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -OutFile ".\.local\tmp\$exename.install.ps1" +echo "Downloading $Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" & curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -o .\.local\tmp\$exename.install.ps1 # Run .ps1 diff --git a/ssh-utils/ssh-pubkey.ps1 b/ssh-utils/ssh-pubkey.ps1 index 46838e3..0951caa 100644 --- a/ssh-utils/ssh-pubkey.ps1 +++ b/ssh-utils/ssh-pubkey.ps1 @@ -26,7 +26,7 @@ if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/config")) if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/id_rsa")) { - & ssh-keygen -b 2048 -t rsa -f "$Env:USERPROFILE/.ssh/id_rsa" -q -N "" + & ssh-keygen -b 2048 -t rsa -f "$Env:USERPROFILE/.ssh/id_rsa" -q -N """" echo "" } -- 2.25.1