Files
wp-agentic-writer/downloads/get-local-ip.sh

35 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
echo "Detecting your local IP address..."
echo ""
# Detect local IP based on OS
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - try en0 (WiFi) then en1 (Ethernet)
IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
INTERFACE=$(ifconfig en0 &>/dev/null && echo "en0 (WiFi)" || echo "en1 (Ethernet)")
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
IP=$(ip route get 1 | awk '{print $7;exit}' 2>/dev/null || hostname -I | awk '{print $1}')
INTERFACE="default"
else
# Windows or unknown
IP=$(hostname -I 2>/dev/null | awk '{print $1}' || echo "")
INTERFACE="unknown"
fi
if [ -z "$IP" ]; then
echo "❌ Could not detect IP address automatically"
echo ""
echo "Manual detection:"
echo " macOS: ipconfig getifaddr en0"
echo " Linux: ip route get 1 | awk '{print \$7}'"
echo " Windows: ipconfig (look for IPv4 Address)"
exit 1
fi
echo "✅ Your local IP: $IP ($INTERFACE)"
echo ""
echo "Use this in your plugin settings:"
echo " Base URL: http://$IP:8080"