diff --git a/.assets/provision/install_argorolloutscli.sh b/.assets/provision/install_argorolloutscli.sh index b6cd231..5b3fe55 100755 --- a/.assets/provision/install_argorolloutscli.sh +++ b/.assets/provision/install_argorolloutscli.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'argoproj' --repo 'argo-rollouts')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_azurecli_uv.sh b/.assets/provision/install_azurecli_uv.sh index 1f197ea..8481eee 100755 --- a/.assets/provision/install_azurecli_uv.sh +++ b/.assets/provision/install_azurecli_uv.sh @@ -30,12 +30,14 @@ version = "1.0.0" requires-python = ">=3.12.8,<3.13" dependencies = [ "azure-cli", - "setuptools", - "pip", "certifi", "idna", "oauthlib", + "pip", + "pycparser", "requests_oauthlib", + "setuptools", + "wrapt", ] [tool.uv] diff --git a/.assets/provision/install_bat.sh b/.assets/provision/install_bat.sh index 5895870..5ddca1b 100755 --- a/.assets/provision/install_bat.sh +++ b/.assets/provision/install_bat.sh @@ -34,7 +34,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'sharkdp' --repo 'bat')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_brew.sh b/.assets/provision/install_brew.sh index ed440b4..8c1094b 100755 --- a/.assets/provision/install_brew.sh +++ b/.assets/provision/install_brew.sh @@ -17,7 +17,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'Homebrew' --repo 'brew')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_crictl.sh b/.assets/provision/install_crictl.sh index ec92317..ec78611 100755 --- a/.assets/provision/install_crictl.sh +++ b/.assets/provision/install_crictl.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'kubernetes-sigs' --repo 'cri-tools')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_etcdctl.sh b/.assets/provision/install_etcdctl.sh index bb1b0c5..108a278 100755 --- a/.assets/provision/install_etcdctl.sh +++ b/.assets/provision/install_etcdctl.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'etcd-io' --repo 'etcd')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_exa.sh b/.assets/provision/install_exa.sh index 3680b0a..2122962 100755 --- a/.assets/provision/install_exa.sh +++ b/.assets/provision/install_exa.sh @@ -34,7 +34,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'ogham' --repo 'exa')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_eza.sh b/.assets/provision/install_eza.sh index 942b63e..318ac75 100755 --- a/.assets/provision/install_eza.sh +++ b/.assets/provision/install_eza.sh @@ -37,7 +37,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'eza-community' --repo 'eza')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_fastfetch.sh b/.assets/provision/install_fastfetch.sh index 2386c77..a20b819 100755 --- a/.assets/provision/install_fastfetch.sh +++ b/.assets/provision/install_fastfetch.sh @@ -31,7 +31,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'fastfetch-cli' --repo 'fastfetch')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_flux.sh b/.assets/provision/install_flux.sh index 07b076b..d8eaf8b 100755 --- a/.assets/provision/install_flux.sh +++ b/.assets/provision/install_flux.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'fluxcd' --repo 'flux2')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_fonts_cascadiacode.sh b/.assets/provision/install_fonts_cascadiacode.sh index 02758ef..d4969e1 100755 --- a/.assets/provision/install_fonts_cascadiacode.sh +++ b/.assets/provision/install_fonts_cascadiacode.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'microsoft' --repo 'cascadia-code')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_fzf.sh b/.assets/provision/install_fzf.sh index 32ffee4..b1db042 100755 --- a/.assets/provision/install_fzf.sh +++ b/.assets/provision/install_fzf.sh @@ -34,7 +34,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'junegunn' --repo 'fzf')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_gh.sh b/.assets/provision/install_gh.sh index b5bd8ea..6e14008 100755 --- a/.assets/provision/install_gh.sh +++ b/.assets/provision/install_gh.sh @@ -38,7 +38,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'cli' --repo 'cli')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_helm.sh b/.assets/provision/install_helm.sh index 42e4488..92b7720 100755 --- a/.assets/provision/install_helm.sh +++ b/.assets/provision/install_helm.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'helm' --repo 'helm')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_k3d.sh b/.assets/provision/install_k3d.sh index b4a777b..cabee91 100755 --- a/.assets/provision/install_k3d.sh +++ b/.assets/provision/install_k3d.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'k3d-io' --repo 'k3d')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_k9s.sh b/.assets/provision/install_k9s.sh index b0a668c..0d26fbf 100755 --- a/.assets/provision/install_k9s.sh +++ b/.assets/provision/install_k9s.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'derailed' --repo 'k9s')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_kubectx.sh b/.assets/provision/install_kubectx.sh index 70c9006..1cc1e6a 100755 --- a/.assets/provision/install_kubectx.sh +++ b/.assets/provision/install_kubectx.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'ahmetb' --repo 'kubectx')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_kubelogin.sh b/.assets/provision/install_kubelogin.sh index df06227..4c1d02f 100755 --- a/.assets/provision/install_kubelogin.sh +++ b/.assets/provision/install_kubelogin.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'Azure' --repo 'kubelogin')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_kustomize.sh b/.assets/provision/install_kustomize.sh index d0b00a0..a55561b 100755 --- a/.assets/provision/install_kustomize.sh +++ b/.assets/provision/install_kustomize.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'kubernetes-sigs' --repo 'kustomize')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_minikube.sh b/.assets/provision/install_minikube.sh index b1670f7..9173955 100755 --- a/.assets/provision/install_minikube.sh +++ b/.assets/provision/install_minikube.sh @@ -28,7 +28,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'kubernetes' --repo 'minikube')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_nerdctl.sh b/.assets/provision/install_nerdctl.sh index 69aee1d..f919871 100755 --- a/.assets/provision/install_nerdctl.sh +++ b/.assets/provision/install_nerdctl.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'containerd' --repo 'nerdctl')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_pwsh.sh b/.assets/provision/install_pwsh.sh index c1cc2b6..cb5e26a 100755 --- a/.assets/provision/install_pwsh.sh +++ b/.assets/provision/install_pwsh.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'PowerShell' --repo 'PowerShell')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_ripgrep.sh b/.assets/provision/install_ripgrep.sh index 876b2de..51b9d16 100755 --- a/.assets/provision/install_ripgrep.sh +++ b/.assets/provision/install_ripgrep.sh @@ -34,7 +34,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'BurntSushi' --repo 'ripgrep')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_terraform.sh b/.assets/provision/install_terraform.sh index 987b59f..cb5d12c 100755 --- a/.assets/provision/install_terraform.sh +++ b/.assets/provision/install_terraform.sh @@ -34,7 +34,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'hashicorp' --repo 'terraform')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_terrascan.sh b/.assets/provision/install_terrascan.sh index 5a71d7d..7b5e084 100755 --- a/.assets/provision/install_terrascan.sh +++ b/.assets/provision/install_terrascan.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'tenable' --repo 'terrascan')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_tfswitch.sh b/.assets/provision/install_tfswitch.sh index 7354e02..b0a8ca5 100755 --- a/.assets/provision/install_tfswitch.sh +++ b/.assets/provision/install_tfswitch.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'warrensbox' --repo 'terraform-switcher')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_uv.sh b/.assets/provision/install_uv.sh index f1907e3..61e1ce0 100755 --- a/.assets/provision/install_uv.sh +++ b/.assets/provision/install_uv.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'astral-sh' --repo 'uv')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/install_yq.sh b/.assets/provision/install_yq.sh index b5db3cf..d90d75b 100755 --- a/.assets/provision/install_yq.sh +++ b/.assets/provision/install_yq.sh @@ -16,7 +16,10 @@ REL=$1 # get latest release if not provided as a parameter if [ -z "$REL" ]; then REL="$(get_gh_release_latest --owner 'mikefarah' --repo 'yq')" - [ -n "$REL" ] || exit 1 + if [ -z "$REL" ]; then + printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2 + exit 1 + fi fi # return the release echo $REL diff --git a/.assets/provision/source.sh b/.assets/provision/source.sh index 8b5f339..4614d77 100755 --- a/.assets/provision/source.sh +++ b/.assets/provision/source.sh @@ -128,9 +128,9 @@ get_gh_release_latest() { fi fi - # Check if the key 'tag_name' exists in the API response - tag_name="$(echo "$api_response" | jq -r 'try .tag_name catch empty')" - if [ 'null' != "$tag_name" ]; then + # Check if 'tag_name' exists + if echo "$api_response" | jq -e '.tag_name | select(. != null and . != "")' >/dev/null; then + tag_name="$(echo "$api_response" | jq -r '.tag_name')" rel="$(echo $tag_name | sed -E 's/[^0-9]*([0-9]+\.[0-9]+\.[0-9]+)/\1/')" if [ -n "$rel" ]; then if [ -n "$asset" ]; then @@ -148,7 +148,7 @@ get_gh_release_latest() { fi return 0 else - printf "\e[31mError: Returned tag_name doesn't conform to the semantic versioning.\e[0m\n" >&2 + printf "\e[31mError: Returned tag_name doesn't conform to the semantic versioning ($tag_name).\e[0m\n" >&2 return 1 fi else diff --git a/.assets/scripts/modules_update.ps1 b/.assets/scripts/modules_update.ps1 index d02df26..6da36d8 100644 --- a/.assets/scripts/modules_update.ps1 +++ b/.assets/scripts/modules_update.ps1 @@ -1,4 +1,5 @@ -#Requires -PSEdition Core +#!/usr/bin/pwsh -nop +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Update repository modules from ps-modules. @@ -98,6 +99,6 @@ process { } } -end { +clean { Pop-Location } diff --git a/.assets/scripts/vg_cacert_fix.ps1 b/.assets/scripts/vg_cacert_fix.ps1 index 5cd2037..b0c1edd 100644 --- a/.assets/scripts/vg_cacert_fix.ps1 +++ b/.assets/scripts/vg_cacert_fix.ps1 @@ -1,5 +1,5 @@ #Requires -RunAsAdministrator -#Requires -PSEdition Core +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Fix self signed certificate error in Vagrant by installing certificates from chain into Vagrant\embedded directory. @@ -65,7 +65,7 @@ process { } } -end { +clean { # return to the original location Pop-Location } diff --git a/modules/SetupUtils/Functions/wsl.ps1 b/modules/SetupUtils/Functions/wsl.ps1 index c73e8fc..b0f7100 100644 --- a/modules/SetupUtils/Functions/wsl.ps1 +++ b/modules/SetupUtils/Functions/wsl.ps1 @@ -48,37 +48,27 @@ function Get-WslDistro { | Where-Object { $_.DistributionName -notmatch '^docker-desktop' } ` | Select-Object $prop } else { - # change console encoding to utf-16 - [Console]::OutputEncoding = [System.Text.Encoding]::Unicode if ($Online) { - # get list of online WSL distros - [string[]]$result = wsl.exe --list --online | Where-Object { $_ } - if (-not $?) { - Write-Error -Message 'Cannot get list of valid distributions.' -Category ConnectionError - } - # get distros header - [string]$head = $result | Select-String 'NAME\s+FRIENDLY' -CaseSensitive | Select-Object -ExpandProperty Line - # calculate header line index - if ($head) { - $idx = $result.IndexOf($head) - $dataIdx = if ($idx -ge 0) { - $idx + 1 - } else { - $result.Count - 1 + # get list of online WSL distros in the loop + $retry = 0 + $distros = $null + do { + try { + $distros = Invoke-RestMethod 'https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json' ` + | Select-Object -ExpandProperty Distributions ` + | Select-Object Name, FriendlyName + } catch { + Out-Null } - # calculate header columns indexes - $nameIdx = $head.IndexOf('NAME') - $friendlyIdx = $head.IndexOf('FRIENDLY') - # add results to the distros list - for ($i = $dataIdx; $i -lt $result.Count; $i++) { - $distro = [PSCustomObject]@{ - Name = $result[$i].Substring($nameIdx, $friendlyIdx - $nameIdx).TrimEnd() - FriendlyName = $result[$i].Substring($friendlyIdx, $result[$i].Length - $friendlyIdx).TrimEnd() - } - $distros.Add($distro) + $retry++ + if ($retry -gt 3) { + Write-Error -Message 'Cannot get list of valid distributions.' -Category ConnectionError + break } - } + } until ($distros) } else { + # change console encoding to utf-16 + [Console]::OutputEncoding = [System.Text.Encoding]::Unicode # get list of installed locally WSL distros [string[]]$result = wsl.exe --list --verbose # get distros header @@ -106,13 +96,16 @@ function Get-WslDistro { } } } - [Console]::OutputEncoding = $outputEncoding } } end { return $distros } + + clean { + [Console]::OutputEncoding = $outputEncoding + } } <# diff --git a/modules/SetupUtils/SetupUtils.psd1 b/modules/SetupUtils/SetupUtils.psd1 index 9a2258a..f434716 100644 --- a/modules/SetupUtils/SetupUtils.psd1 +++ b/modules/SetupUtils/SetupUtils.psd1 @@ -12,7 +12,7 @@ RootModule = 'SetupUtils.psm1' # Version number of this module. - ModuleVersion = '0.4.0' + ModuleVersion = '0.5.0' # Supported PSEditions CompatiblePSEditions = @('Core') @@ -33,7 +33,7 @@ # Description = '' # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '7.0' + PowerShellVersion = '7.3' # Name of the PowerShell host required by this module # PowerShellHostName = '' diff --git a/scripts_egsave.ps1 b/scripts_egsave.ps1 index 242c749..fc2b481 100644 --- a/scripts_egsave.ps1 +++ b/scripts_egsave.ps1 @@ -1,5 +1,5 @@ -#Requires -PSEdition Core #!/usr/bin/pwsh -nop +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Generate example scripts from the current repository. @@ -35,6 +35,6 @@ process { } } -end { +clean { Pop-Location } diff --git a/wsl/wsl_certs_add.ps1 b/wsl/wsl_certs_add.ps1 index dee9408..5cf6603 100644 --- a/wsl/wsl_certs_add.ps1 +++ b/wsl/wsl_certs_add.ps1 @@ -1,4 +1,4 @@ -#Requires -PSEdition Core +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Get certificates in chain and install them in the specified WSL distribution. @@ -124,7 +124,9 @@ process { wsl -d $Distro -u root --exec bash -c $cmd } -end { - Remove-Item $tmpFolder -Recurse +clean { + if (Test-Path $tmpFolder -PathType Container) { + Remove-Item $tmpFolder -Recurse + } Pop-Location } diff --git a/wsl/wsl_files_copy.ps1 b/wsl/wsl_files_copy.ps1 index c216196..83ce1d2 100644 --- a/wsl/wsl_files_copy.ps1 +++ b/wsl/wsl_files_copy.ps1 @@ -1,4 +1,4 @@ -#Requires -PSEdition Core +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Copy files between WSL distributions. @@ -105,7 +105,7 @@ process { Invoke-Expression "wsl.exe -d $dstDistro $($Root ? '--user root ' : '')--exec bash -c '$cmnd'" } -end { +clean { # move source to original location if ($useTmp) { $cmnd = "mv `"/tmp/cpf/$(Split-Path $srcPath -Leaf)`" `"$($rlPath)`" && rm -fr /tmp/cpf" diff --git a/wsl/wsl_setup.ps1 b/wsl/wsl_setup.ps1 index 5c7d08d..dfbd88b 100644 --- a/wsl/wsl_setup.ps1 +++ b/wsl/wsl_setup.ps1 @@ -1,4 +1,4 @@ -#Requires -PSEdition Core +#Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS Setting up WSL distro(s). @@ -542,6 +542,9 @@ process { } end { - Pop-Location Write-Host "`n`e[1;95m<< WSL setup completed >>`e[0m`n" } + +clean { + Pop-Location +}