Skip to content

Instantly share code, notes, and snippets.

@nckswt
Last active August 14, 2024 18:42
Show Gist options
  • Save nckswt/c6e5543642a45e2c04fd5b40355464a5 to your computer and use it in GitHub Desktop.
Save nckswt/c6e5543642a45e2c04fd5b40355464a5 to your computer and use it in GitHub Desktop.
Bash script to verify network connectivity for a Tailos robot over Wifi
#!/bin/bash
# List of endpoints and TCP ports to check
# Note: Not checking UDP ports. See ref: https://serverfault.com/a/416269
endpoints=(
"ota-lite.foundries.io:8443"
"ostree.foundries.io:8443"
"hub.foundries.io:443"
"hub-auth.foundries.io:443"
"storage.googleapis.com:443"
"api.foundries.io:443"
"app.foundries.io:443"
"lore-telemetry.maidbot.io:443"
"lore-telemetry.tailos.io:443"
"lore-parameter.maidbot.io:443"
"lore-parameter.tailos.io:443"
"lore-log.maidbot.io:443"
"lore-log.tailos.io:443"
"lore-ml.maidbot.io:443"
"lore-ml.tailos.io:443"
"lore-task.maidbot.io:443"
"lore-task.tailos.io:443"
"tycho-maps-prd.s3.amazonaws.com:443"
)
function network_timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
if ! command -v nc &> /dev/null; then
printf "netcat command is not available -- please install netcat.\n"
exit -1
fi
printf -v results "%-40s %4s\n" "ENDPOINT" "STATUS"
# Loop through each endpoint
for endpoint in "${endpoints[@]}"; do
# Extract the endpoint and port
endpoint_host=$(echo $endpoint | cut -d ':' -f 1)
endpoint_port=$(echo $endpoint | cut -d ':' -f 2)
echo "Checking connectivity to $endpoint_host on port $endpoint_port..."
# Use netcat to check connectivity
if echo -e "" | network_timeout 3 nc -zv $endpoint_host $endpoint_port 2>&1 | grep "succeeded!"; then
result="PASS"
else
result="FAIL"
fi
printf -v result_line "%-40s %4s\n" "$endpoint" "[ $result ]"
results+="$result_line"
echo
done
echo -e "$results"
@nckswt
Copy link
Author

nckswt commented Aug 14, 2024

Purpose

This script will verify connectivity with Tailos and related third-party endpoints. You can run this on a machine connected to the same network as Tailos robots to ensure the network is configured correctly for endpoint access. Note that robots may still not be able to connect to Tailos services if other network configurations are invalid (e.g. if a robot is not allow-listed for WLAN access).

Use

You can copy and paste any of these commands to run in a terminal on your local machine.

On Unix (Linux or macOS)

Using curl:

bash <(curl -s https://gist.githubusercontent.com/nckswt/c6e5543642a45e2c04fd5b40355464a5/raw)

Using wget:

bash <(wget -qO- https://gist.githubusercontent.com/nckswt/c6e5543642a45e2c04fd5b40355464a5/raw)

On Windows (using Git Bash or Windows Subsystem for Linux (WSL))

You can use the same commands as above in Git Bash or WSL like so:

wsl bash -c "$(curl -fsSL https://gist.githubusercontent.com/nckswt/c6e5543642a45e2c04fd5b40355464a5/raw)"

On Windows (using Command Prompt or PowerShell)

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment