#!/usr/app/TurboShell/bin/bash
# Czyta wynik smartctl -A i pokazuje, co wymaga uwagi
set -euo pipefail
bad=0
while read -r id name _ _ _ _ _ _ _ raw _; do
  [[ $id =~ ^[0-9]+$ ]] || continue
  case $name in
    Reallocated_Sector_Ct | Current_Pending_Sector | Offline_Uncorrectable | UDMA_CRC_Error_Count)
      mark=ok
      if ((raw > 0)); then
        mark=UWAGA
        bad=$((bad + 1))
      fi
      printf '%-6s %s %s\n' "$mark" "$name" "$raw"
      ;;
    Temperature_Celsius) echo "       temperatura $raw C" ;;
    Power_On_Hours) echo "       pracuje od $((raw / 24)) dni" ;;
  esac
done
echo "wartości do sprawdzenia: $bad"
((bad == 0))
