#!/usr/bin/env zsh # Locate the repository from this file, independent of Windows/WSL working directories. project_root="${0:A:h:h:h}" cd -- "$project_root" || exit 1 ./planet.sh restart --allow-lan planet_exit=$? print if (( planet_exit == 0 )); then print 'Planet restart finished successfully.' frontend_port=3000 frontend_scheme=http port_state="${PLANET_STATE_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/planet}/ports.env" if [[ -f "$port_state" ]]; then while IFS='=' read -r key value; do case "$key" in FRONTEND_PORT) [[ "$value" == <1-65535> ]] && frontend_port="$value" ;; FRONTEND_SCHEME) [[ "$value" == http || "$value" == https ]] && frontend_scheme="$value" ;; esac done < "$port_state" fi WSLENV="${WSLENV:+$WSLENV:}PLANET_LAUNCH_URL" \ PLANET_LAUNCH_URL="${frontend_scheme}://localhost:${frontend_port}/earth" \ powershell.exe -NoProfile -Command 'Start-Process $env:PLANET_LAUNCH_URL' else print "Planet restart failed with exit code $planet_exit." fi print print 'Staying in WSL. Close this terminal manually when you are done.' exec zsh -l