#!/bin/sh # Reports whether this shell can reach the network. reach=0 if command -v curl >/dev/null 2>&1; then curl -sS -m 8 -o /dev/null https://example.com 2>/dev/null && reach=1 fi python3 - <<'PY' && reach=1 import socket, sys try: socket.create_connection(("1.1.1.1", 443), 5).close() except OSError: sys.exit(1) PY getent hosts example.com >/dev/null 2>&1 && echo "DNS_RESOLVES" if [ "$reach" = 1 ]; then echo "NETWORK_REACHABLE"; else echo "NETWORK_BLOCKED"; fi