Added WSL2 support for installer

This commit is contained in:
nlovlyn 2026-03-14 14:37:15 -07:00
parent 86575bfc73
commit fe99e30863

View File

@ -142,6 +142,11 @@ generateRandomPass() {
echo "$password" echo "$password"
} }
is_wsl() {
# True if running inside WSL
grep -qiE 'microsoft|wsl' /proc/version 2>/dev/null
}
ensure_docker_installed() { ensure_docker_installed() {
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then
echo -e "${YELLOW}#${RESET} Docker not found. Installing Docker...\\n" echo -e "${YELLOW}#${RESET} Docker not found. Installing Docker...\\n"
@ -185,7 +190,15 @@ ensure_docker_installed() {
echo -e "${GREEN}#${RESET} Docker installation completed.\\n" echo -e "${GREEN}#${RESET} Docker installation completed.\\n"
else else
echo -e "${GREEN}#${RESET} Docker is already installed.\\n" echo -e "${GREEN}#${RESET} Docker is already installed.\n"
# On WSL, if Docker is reachable, skip systemd checks (Docker Desktop case)
if is_wsl; then
if docker version >/dev/null 2>&1; then
echo -e "${GREEN}#${RESET} Docker is reachable (WSL/Docker Desktop). Skipping systemctl checks.\\n"
return 0
fi
fi
# Check if Docker service is running # Check if Docker service is running
if ! systemctl is-active --quiet docker; then if ! systemctl is-active --quiet docker; then
@ -203,6 +216,7 @@ ensure_docker_installed() {
fi fi
} }
setup_nvidia_container_toolkit() { setup_nvidia_container_toolkit() {
# This function attempts to set up NVIDIA GPU support but is non-blocking # This function attempts to set up NVIDIA GPU support but is non-blocking
# Any failures will result in warnings but will NOT stop the installation process # Any failures will result in warnings but will NOT stop the installation process
@ -309,11 +323,21 @@ setup_nvidia_container_toolkit() {
# Restart Docker service # Restart Docker service
echo -e "${YELLOW}#${RESET} Restarting Docker service...\\n" echo -e "${YELLOW}#${RESET} Restarting Docker service...\\n"
if ! sudo systemctl restart docker 2>/dev/null; then if is_wsl; then
echo -e "${YELLOW}#${RESET} Warning: Failed to restart Docker service. You may need to restart it manually.\\n" # On WSL with Docker Desktop, there is no local docker.service; just check connectivity.
return 0 if ! docker info >/dev/null 2>&1; then
echo -e "${YELLOW}#${RESET} Warning: Cannot restart Docker via systemd on WSL. Make sure Docker Desktop is running.\\n"
else
echo -e "${GREEN}#${RESET} Docker is reachable on WSL. Skipping systemctl restart.\\n"
fi
else
if ! sudo systemctl restart docker 2>/dev/null; then
echo -e "${YELLOW}#${RESET} Warning: Failed to restart Docker service. You may need to restart it manually.\\n"
return 0
fi
fi fi
# Verify NVIDIA runtime is available # Verify NVIDIA runtime is available
echo -e "${YELLOW}#${RESET} Verifying NVIDIA runtime configuration...\\n" echo -e "${YELLOW}#${RESET} Verifying NVIDIA runtime configuration...\\n"
sleep 2 # Give Docker a moment to fully restart sleep 2 # Give Docker a moment to fully restart
@ -570,10 +594,15 @@ verify_gpu_setup() {
echo -e "${GREEN}#${RESET} GPU acceleration is properly configured! The AI Assistant will use your GPU.\\n" echo -e "${GREEN}#${RESET} GPU acceleration is properly configured! The AI Assistant will use your GPU.\\n"
else else
echo -e "${YELLOW}#${RESET} GPU acceleration not detected. The AI Assistant will run in CPU-only mode.\\n" echo -e "${YELLOW}#${RESET} GPU acceleration not detected. The AI Assistant will run in CPU-only mode.\\n"
if command -v nvidia-smi &> /dev/null && ! docker info 2>/dev/null | grep -q \"nvidia\"; then if command -v nvidia-smi &> /dev/null && ! docker info 2>/dev/null | grep -q "nvidia"; then
echo -e "${YELLOW}#${RESET} Tip: Your GPU is detected but Docker runtime is not configured.\\n" echo -e "${YELLOW}#${RESET} Tip: Your GPU is detected but Docker runtime is not configured.\\n"
echo -e "${YELLOW}#${RESET} Try restarting Docker: ${WHITE_R}sudo systemctl restart docker${RESET}\\n" if is_wsl; then
echo -e "${YELLOW}#${RESET} On WSL, restart Docker Desktop from Windows after changing GPU settings.\\n"
else
echo -e "${YELLOW}#${RESET} Try restarting Docker: ${WHITE_R}sudo systemctl restart docker${RESET}\\n"
fi
fi fi
fi fi
} }