feat: show public IP location in pos network ip

This commit is contained in:
Your Name
2026-08-05 03:57:21 -04:00
parent 93f3044c2a
commit d591e71363
3 changed files with 26 additions and 4 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ Linux_post_install/
├── bin/ # CLI tools — installed to /usr/local/bin/
│ ├── pos # Main dispatcher — smart arg matching to pos-* scripts
│ ├── pos-network-ip # Show interfaces, routes, public IP
│ ├── pos-network-ip # Show interfaces, routes, public IP + location
│ ├── pos-network-checkport # TCP port checker
│ ├── pos-network-scan # Parallel ping sweep of CIDR subnet
│ ├── pos-docker-ps # Enhanced docker ps (health, IPs, ports, uptime)
@@ -196,7 +196,7 @@ All non-interactive `pos` commands log output to `~/.local/share/linux_post_inst
| Category | Command | Script | Description |
|----------|---------|--------|-------------|
| network | ip | `pos-network-ip` | Show interfaces, routes, public IP |
| network | ip | `pos-network-ip` | Show interfaces, routes, public IP + location |
| network | checkport | `pos-network-checkport` | Check TCP port connectivity |
| network | scan | `pos-network-scan` | Parallel ping sweep of CIDR |
| docker | ps | `pos-docker-ps` | Enhanced container overview |
+1 -1
View File
@@ -50,7 +50,7 @@ Every non-interactive `pos` invocation logs to `~/.local/share/linux_post_instal
| Command | File | Purpose | Configuration |
|---------|------|---------|---------------|
| `pos network ip` | `bin/pos-network-ip` | Show interfaces, default route, public IP | None. Public IP via `https://ifconfig.me` (5s timeout) |
| `pos network ip` | `bin/pos-network-ip` | Show interfaces, default route, public IP + location | None. Public IP via `https://ifconfig.me`; location via `ip-api.com` (5s timeouts) |
| `pos network checkport <ip:port>` | `bin/pos-network-checkport` | Check if a TCP port is open | None. Uses `/dev/tcp` with a 2s timeout; exit 0/1 via OPEN/CLOSED |
| `pos network scan <cidr> [--full] [--retries N]` | `bin/pos-network-scan` | Two-phase nmap scan | See below |
| `pos network hotspot [cmd]` | `bin/pos-network-hotspot` | Wi-Fi hotspot via `create_ap` (CLI) or `wihotspot-gui` (GUI) | Uses the precompiled binaries from `x64_bin/`; see below |
+23 -1
View File
@@ -42,5 +42,27 @@ SEP
echo "Public IP"
SEP
curl -4 -s --max-time 5 https://ifconfig.me 2>/dev/null || echo "Unavailable"
PUBLIC_IP=$(curl -4 -s --max-time 5 https://ifconfig.me 2>/dev/null) || true
if [ -n "${PUBLIC_IP:-}" ]; then
echo "$PUBLIC_IP"
GEO=$(curl -4 -s --max-time 5 "http://ip-api.com/json/${PUBLIC_IP}?fields=status,country,regionName,city,isp" 2>/dev/null) || true
if [ -n "${GEO:-}" ]; then
location=$(echo "$GEO" | python3 -c "
import sys, json
d = json.load(sys.stdin)
if d.get('status') == 'success':
print(f\"{d['city']}, {d['regionName']}, {d['country']} ({d['isp']})\")
" 2>/dev/null) || true
if [ -n "${location:-}" ]; then
printf "%-20s %s\n" "Location" "$location"
else
echo "Location: Unavailable"
fi
else
echo "Location: Unavailable"
fi
else
echo "Unavailable"
fi
echo