2023-09-06 04:11:20 +00:00
|
|
|
param([switch] $remote = $false)
|
2023-09-06 04:04:33 +00:00
|
|
|
|
2023-09-06 06:32:55 +00:00
|
|
|
Write-Host "OSIC-Stacks Container Creation" -ForegroundColor Green
|
|
|
|
Write-Host "Please select an image index:"
|
|
|
|
|
|
|
|
$imageoptions = @(
|
|
|
|
'analog-xk'
|
|
|
|
'analog-xm'
|
|
|
|
'digital-ator'
|
|
|
|
'digital-icarus'
|
|
|
|
'heavy'
|
|
|
|
)
|
|
|
|
|
|
|
|
for($i = 0; $i -lt $imageoptions.Length; $i++) {
|
|
|
|
$imageoption = $imageoptions[$i]
|
|
|
|
Write-Host "$i - $imageoption" -ForegroundColor Cyan
|
|
|
|
}
|
|
|
|
|
|
|
|
$imageindex = Read-Host -Prompt "Container image to initialize [0-$($imageoptions.Length)]"
|
|
|
|
$imagename = $imageoptions[$imageindex]
|
|
|
|
$containername = Read-Host -Prompt "Container instance name [default=$imagename]"
|
2023-09-03 22:53:58 +00:00
|
|
|
if (!$containername) { $containername = $imagename }
|
|
|
|
|
2023-09-06 04:45:53 +00:00
|
|
|
if($remote) {
|
2023-09-06 04:04:33 +00:00
|
|
|
$image = "git.1159.cl/mario1159/$imagename"
|
|
|
|
} else {
|
|
|
|
$image = $imagename
|
|
|
|
}
|
|
|
|
|
2023-09-06 06:32:55 +00:00
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
$dockercommand = ("docker run -d " +
|
2023-09-06 04:04:33 +00:00
|
|
|
"--name $containername " +
|
2023-09-03 22:53:58 +00:00
|
|
|
"-v /tmp/.X11-unix:/tmp/.X11-unix " +
|
|
|
|
"-v /mnt/wslg:/mnt/wsl " +
|
|
|
|
"-e WAYLAND_DISPLAY=`$WAYLAND_DISPLAY " +
|
|
|
|
"-e DISPLAY=`$DISPLAY " +
|
|
|
|
"-e XDG_RUNTIME_DIR=/mnt/wslg " +
|
2023-09-06 04:04:33 +00:00
|
|
|
$image)
|
2023-09-03 22:53:58 +00:00
|
|
|
|
2023-09-06 06:32:55 +00:00
|
|
|
wsl bash -ic $dockercommand
|
|
|
|
|
|
|
|
if ($?) {
|
|
|
|
Write-Host "Container created successfully!" -ForegroundColor Green
|
|
|
|
Write-Host "Enter the container with `"docker exec -it $containername bash`"" -ForegroundColor DarkGray
|
|
|
|
} else {
|
|
|
|
Write-Host "Container creation failed, see logs above" -ForegroundColor Red
|
|
|
|
}
|