|
$dockerExists = Test-Path "c:\temp\docker" |
|
$podmanExists = Test-Path "c:\temp\podman" |
|
$gotoFolderPath = "$env:USERPROFILE\OneDrive\Goto\" |
|
$gotoFolderExists = Test-Path $gotoFolderPath |
|
|
|
$manageDevboxFilePath = "D:\Repos\Github\hasmukhlalpatel\dev-container-on-lxd-or-wsl\setup-devbox-on-wsl\manage-devbox.ps1" |
|
$manageDevboxExists = Test-Path $manageDevboxFilePath |
|
|
|
function get-file { |
|
param( |
|
[Parameter(Mandatory=$true)] |
|
[string]$FileName |
|
) |
|
|
|
$FilePath = Join-Path $gotoFolderPath $FileName |
|
|
|
if (Test-Path $FilePath) { |
|
Write-Host "File found: $FilePath" -ForegroundColor Green |
|
Write-Host "File content:" -ForegroundColor Yellow |
|
Write-Host ("=" * 50) -ForegroundColor Yellow |
|
type $FilePath |
|
|
|
Write-Host ("=" * 50) -ForegroundColor Yellow |
|
} |
|
else { |
|
Write-Host "File not found: $FilePath" -ForegroundColor Red |
|
} |
|
} |
|
|
|
function my-help { |
|
Write-Host "type wsl-help, podman-help, k3s-help or Get-help" -ForegroundColor Green |
|
Write-Host "type wslsetup for wsl interactive script setup help" -ForegroundColor Green |
|
} |
|
|
|
Write-Host "Type `my-help` for any help" -ForegroundColor yellow |
|
|
|
if($gotoFolderExists){ |
|
# Create functions for specific files |
|
function Get-WSL-File { get-file -FileName "wsl-commands.txt" } |
|
function Get-Podman-File { get-file -FileName "podman-commands.txt" } |
|
function Get-K3S-File { get-file -FileName "k3s-commands.txt" } |
|
function Get-Any-File { get-file -FileName "${args}" } |
|
|
|
# Set aliases |
|
Set-Alias -Name wsl-help -Value Get-WSL-File |
|
Set-Alias -Name podman-help -Value Get-Podman-File |
|
Set-Alias -Name k3s-help -Value Get-K3S-File |
|
Set-Alias -Name Get-help -Value Get-Any-File |
|
} |
|
|
|
if($manageDevboxExists){ |
|
function wslsetup { & $manageDevboxFilePath @args } |
|
} |
|
|
|
if ($dockerExists -and $podmanExists) { |
|
Write-Host "Both c:\temp\docker and c:\temp\podman exist." -ForegroundColor Green |
|
} elseif ($dockerExists) { |
|
Write-Host "Only c:\temp\docker exists." |
|
} elseif ($podmanExists) { |
|
Write-Host "Only c:\temp\podman exists." -ForegroundColor Green |
|
} else { |
|
Write-Host "Neither c:\temp\docker nor c:\temp\podman exists." -ForegroundColor yellow |
|
exit |
|
} |
|
|
|
# PowerShell Profile: Use Podman (WSL) from Windows |
|
$distroName = "devbox" |
|
# Optional: Show a friendly startup message |
|
Write-Host "PowerShell Dev Environment Loaded (WSL + Podman or Docker)" -ForegroundColor Cyan |
|
Write-Host "Podman or Docker command will run in ${distroName} Distro" -ForegroundColor yellow |
|
Write-Host "To Edit defaut file, Open Powershell in Admin Mode and run 'notepad `$PROFILE'" -ForegroundColor Red |
|
|
|
Function Start-WslDocker_1 { |
|
wsl docker $args |
|
} |
|
|
|
Function Start-WslDockerCompose_1 { |
|
wsl docker-compose $args |
|
} |
|
|
|
Function Start-WslDocker { |
|
wsl -d $distroName -- bash -c "podman ${args}" |
|
} |
|
|
|
Function Start-WslDockerCompose { |
|
wsl -d $distroName -- bash -c "podman-compose ${args}" |
|
} |
|
|
|
Function Start-WslCode { |
|
wsl -d $distroName -- bash -c "code ${args}" |
|
} |
|
|
|
Set-Alias -Name docker -Value Start-WslDocker |
|
Set-Alias -Name docker-compose -Value Start-WslDockerCompose |
|
|
|
Set-Alias -Name podman -Value Start-WslDocker |
|
Set-Alias -Name podman-compose -Value Start-WslDockerCompose |
|
Set-Alias -Name wsl-code -Value Start-WslCode |
|
|
|
# Example aliases |
|
Set-Alias k kubectl |
|
Set-Alias pod podman |
|
|
|
#Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned |
|
#Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass |
|
#Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned |
|
|