Skip to content

Commit

Permalink
refactor(ps): wsl_setup - install messages
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonos committed Oct 7, 2023
1 parent 4c1d62c commit c1d7136
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions wsl/wsl_install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ process {
if ($AddCertificate) { $sb.Append(" -AddCertificate") | Out-Null }
$sb.Append(" -OmpTheme 'base'") | Out-Null
# run the wsl_setup script
Write-Host '*** WSL Setup ***' -ForegroundColor White
pwsh.exe -NoProfile -Command $sb.ToString()
}

Expand Down
9 changes: 5 additions & 4 deletions wsl/wsl_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ begin {
Import-Module (Resolve-Path './modules/InstallUtils')

# check if repository is up to date
Write-Host "`nchecking if the repository is up to date..." -ForegroundColor Cyan
git fetch
$remote = "$(git remote)/$(git branch --show-current)"
if ((git rev-parse HEAD) -ne (git rev-parse $remote)) {
Expand All @@ -136,7 +137,7 @@ begin {
$onlineDistros = wsl/wsl_distro_get.ps1 -Online
# install online distro
if ($Distro -in $onlineDistros.Name) {
Write-Host "Specified distribution not found ($Distro). Proceeding to install." -ForegroundColor Cyan
Write-Host "`nspecified distribution not found ($Distro), proceeding to install..." -ForegroundColor Cyan
$cmd = "wsl.exe --install --distribution $Distro"
try {
Get-Service LxssManagerUser*, WSLService | Out-Null
Expand All @@ -163,6 +164,7 @@ begin {
$lxss = wsl/wsl_distro_get.ps1 -FromRegistry | Where-Object Name -EQ $Distro
if ($lxss -and $lxss.Flags -ne 13) {
Set-ItemProperty -Path $lxss.PSPath -Name 'Flags' -Value 13
Write-Host "`nrestarting WSL to apply changes..." -ForegroundColor Cyan
wsl.exe --shutdown $Distro
}
} elseif ($lxss) {
Expand All @@ -171,7 +173,7 @@ begin {
$lxss.Count ? '' : $null
} else {
Write-Warning 'No installed WSL distributions found.'
exit 1
exit 0
}

# determine GTK theme if not provided, based on system theme
Expand Down Expand Up @@ -240,8 +242,7 @@ process {
$scopes.Remove('k8s_ext') | Out-Null
}
# display distro name and installed scopes
$follow = $Distro -eq $lxss[0].Name ? '' : "`n"
Write-Host "$follow`e[95;1m${Distro}$($scopes.Count ? " :`e[0;90m $($scopes -join ', ')`e[0m" : "`e[0m")"
Write-Host "`n`e[95;1m${Distro}$($scopes.Count ? " :`e[0;90m $($scopes -join ', ')`e[0m" : "`e[0m")"
# *fix WSL networking
if ($FixNetwork) {
Write-Host 'fixing network...' -ForegroundColor Cyan
Expand Down

0 comments on commit c1d7136

Please sign in to comment.