Skip to content

Commit

Permalink
scripts: init-workspace: Use the powershell absolute path
Browse files Browse the repository at this point in the history
To share the wsl ports with Windows we need to use the powershell
from the host. But the path inside the container does not work.
So, we need to use the absolute path to the powershell in the host.

Signed-off-by: Matheus Castello <[email protected]>
  • Loading branch information
microhobby committed Jan 18, 2025
1 parent deea636 commit 6378eaf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/init-workspace.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ else:
if "WSL_DISTRO_NAME" in os.environ:
print("🔧 :: Sharing WSL ports with Windows :: 🔧")
print("")
sudo nsenter -t 1 -m -u -n -i -- powershell.exe -NoProfile -C "start-process powershell -verb runas -ArgumentList '-NoProfile -C \"(Remove-NetFireWallRule -DisplayName ApolloX) -or \$true ; New-NetFireWallRule -DisplayName ApolloX -Direction Outbound -LocalPort 8090,5002 -Action Allow -Protocol TCP ; New-NetFireWallRule -DisplayName ApolloX -Direction Inbound -LocalPort 8090,5002 -Action Allow -Protocol TCP ; (netsh interface portproxy delete v4tov4 listenport=8090 listenaddress=0.0.0.0) -or \$true ; (netsh interface portproxy delete v4tov4 listenport=5002 listenaddress=0.0.0.0) -or \$true ; (netsh interface portproxy add v4tov4 listenport=8090 listenaddress=0.0.0.0 connectport=8090 connectaddress=172.24.54.164) -or \$true ; (netsh interface portproxy add v4tov4 listenport=5002 listenaddress=0.0.0.0 connectport=5002 connectaddress=172.24.54.164) -or \$true ; echo done\"'"

# first check if the powershell is available
if not os.path.exists("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"):
Error_Out(
"❌ :: PowerShell not found in Windows path [/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe] :: ❌",
Error.ENOFOUND
)

sudo nsenter -t 1 -m -u -n -i -- /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -C "start-process powershell -verb runas -ArgumentList '-NoProfile -C \"(Remove-NetFireWallRule -DisplayName ApolloX) -or \$true ; New-NetFireWallRule -DisplayName ApolloX -Direction Outbound -LocalPort 8090,5002 -Action Allow -Protocol TCP ; New-NetFireWallRule -DisplayName ApolloX -Direction Inbound -LocalPort 8090,5002 -Action Allow -Protocol TCP ; (netsh interface portproxy delete v4tov4 listenport=8090 listenaddress=0.0.0.0) -or \$true ; (netsh interface portproxy delete v4tov4 listenport=5002 listenaddress=0.0.0.0) -or \$true ; (netsh interface portproxy add v4tov4 listenport=8090 listenaddress=0.0.0.0 connectport=8090 connectaddress=172.24.54.164) -or \$true ; (netsh interface portproxy add v4tov4 listenport=5002 listenaddress=0.0.0.0 connectport=5002 connectaddress=172.24.54.164) -or \$true ; echo done\"'"
print("")

print("🔧 :: Running Local Registry :: 🔧")
Expand Down

0 comments on commit 6378eaf

Please sign in to comment.