#!/usr/bin/env bash # ROS2Lab - Check my PC (Ubuntu and other Linux, also Ubuntu inside WSL2 or a virtual machine). # # curl --proto '=https' --tlsv1.2 -fsSL https://www.ros2lab.com/install/check.sh | bash # # READ-ONLY. It installs nothing, changes nothing, needs no password and writes no file. # What it reads: /etc/os-release, uname, /proc/cpuinfo, /proc/meminfo, df (free space of your home folder), lspci and # /sys (graphics card and its driver), glxinfo and vulkaninfo when they are installed, systemd-detect-virt, and one # download from packages.ros.org (the ROS 2 package list, up to 8 seconds, thrown away) to see your internet speed. # Where the result goes: it is printed here. Then it is kept ready on THIS computer only (127.0.0.1, port 7776) for up to # 10 minutes, so that the ROS2Lab page open in your browser can read it when you press "Read the result from my PC". # Nothing is sent to the internet. Ctrl+C stops it at any time. ROS2LAB_NO_SERVE=1 prints only. set -u ORIGIN="${ROS2LAB_ORIGIN:-https://www.ros2lab.com}"; PORT="${ROS2LAB_CHECK_PORT:-7776}" have() { command -v "$1" >/dev/null 2>&1; } one() { tr '\n' ' ' | sed 's/ */ /g; s/^ //; s/ $//'; } [ -r /etc/os-release ] && . /etc/os-release os="${PRETTY_NAME:-$(uname -s)}"; os_id="${ID:-unknown}"; os_version="${VERSION_ID:-unknown}" wsl=no; grep -qi microsoft /proc/version 2>/dev/null && wsl=yes vm=unknown; have systemd-detect-virt && vm=$(systemd-detect-virt 2>/dev/null | head -1); [ -n "$vm" ] || vm=unknown cpu=$(awk -F': ' '/^model name/{print $2; exit}' /proc/cpuinfo 2>/dev/null); [ -n "$cpu" ] || cpu=$(lscpu 2>/dev/null | awk -F': +' '/^Model name/{print $2; exit}') cores=$(nproc 2>/dev/null || echo unknown) ram_gb=$(awk '/^MemTotal/{printf "%.1f", $2/1048576}' /proc/meminfo 2>/dev/null) disk_free_gb=$(df -Pk "$HOME" 2>/dev/null | awk 'NR==2{printf "%.1f", $4/1048576}') gpu=unknown; gpu_driver=unknown if have lspci; then g=$(lspci -nn 2>/dev/null | grep -E '\[03(00|02|80)\]' | sed -E 's/^[^:]+:[^:]+: //; s/ \[[0-9a-f]{4}:[0-9a-f]{4}\].*$//' | paste -sd'|' | sed 's/|/ + /g') d=$(lspci -nnk 2>/dev/null | awk '/\[03(00|02|80)\]/{on=1; next} /^[0-9a-f]/{on=0} on && /Kernel driver in use/{print $5}' | paste -sd'|' | sed 's/|/ + /g') [ -n "$g" ] && gpu=$g; [ -n "$d" ] && gpu_driver=$d fi [ "$wsl" = yes ] && [ -e /dev/dxg ] && [ "$gpu" = unknown ] && { gpu="the Windows graphics card (through WSL)"; gpu_driver=dxg; } [ -r /sys/module/nvidia/version ] && gpu_driver="$gpu_driver (nvidia $(cat /sys/module/nvidia/version))" display=none; [ -n "${WAYLAND_DISPLAY:-}" ] && display=wayland; [ "$display" = none ] && [ -n "${DISPLAY:-}" ] && display=x11 opengl="unknown (glxinfo is not installed yet)"; gl_renderer=unknown if [ "$display" = none ]; then opengl="unknown (no screen in this terminal)" elif have glxinfo; then gi=$(timeout 10 glxinfo -B 2>/dev/null) o=$(printf '%s\n' "$gi" | awk -F': ' '/OpenGL core profile version string|OpenGL version string/{print $2; exit}') r=$(printf '%s\n' "$gi" | awk -F': ' '/OpenGL renderer string/{print $2; exit}') [ -n "$o" ] && opengl=$o; [ -n "$r" ] && gl_renderer=$r fi vulkan="unknown (vulkaninfo is not installed)" if have vulkaninfo && [ "$display" != none ]; then x=$(timeout 10 vulkaninfo --summary 2>/dev/null | awk -F'= ' '/apiVersion/{print $2; exit}'); [ -n "$x" ] && vulkan=$x; fi # a new Ubuntu desktop has wget but no curl: count the bytes that arrive in at most 8 seconds (nothing is saved) net_ros=no; net_mbps=0; U=http://packages.ros.org/ros2/ubuntu/dists/noble/main/binary-amd64/Packages t0=$(date +%s%N) if have wget; then n=$( (timeout 8 wget -q -O - "$U" 2>/dev/null || true) | wc -c ) elif have curl; then n=$( (curl -s --max-time 8 "$U" 2>/dev/null || true) | wc -c ) else n=0; fi t1=$(date +%s%N) if [ "${n:-0}" -gt 10000 ]; then net_ros=yes; net_mbps=$(awk -v n="$n" -v a="$t0" -v b="$t1" 'BEGIN{printf "%.1f", n*8/((b-a)/1e9)/1e6}'); fi R=$(cat <