diagnostics.cgi 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # diagnostics
  3. . /opt/wz_mini/www/cgi-bin/shared.cgi
  4. title="Diagnostics $camver on $camfirmware running wz_mini $hackver as $HOSTNAME"
  5. function handle_css
  6. {
  7. echo -ne "<style type=\"text/css\">"
  8. cat config.css
  9. echo -ne '</style>';
  10. }
  11. dmesg_test()
  12. {
  13. x=$(dmesg | grep "$1")
  14. if [ -n "$x" ]; then
  15. echo "<div>$2 error found</div>"
  16. else
  17. echo "<div>no $2 error</div>"
  18. fi
  19. }
  20. logread_test()
  21. {
  22. x=$(logread | grep "$1")
  23. if [ -n "$x" ]; then
  24. echo "<div>$2 error found</div>"
  25. else
  26. echo "<div>no $2 error</div>"
  27. fi
  28. }
  29. echo "HTTP/1.1 200"
  30. echo -e "Content-type: text/html\n\n"
  31. echo ""
  32. echo "<html><head><title>$title</title>"
  33. handle_css
  34. echo "</head>"
  35. echo "<body>"
  36. echo "<h1>$title</h1>"
  37. echo "<h2>SD Card Test</h2>"
  38. dmesg_test "invalid access to FAT" "SD card"
  39. dmesg_test "Filesystem has been set read-only" "SD read only"
  40. dmesg_test "fat_get_cluster: invalid cluster chain" "file system"
  41. logread_test "run: tf_prepare failed!" "SD card (tf_prepare)"
  42. logread_test "(health_test) fail" "SD card health fail"
  43. echo "<h2>Firmware Version Test</h2>"
  44. echo "Firmware Version: $camfirmware <br />"
  45. if [ "$camfirmware" = "4.36.10.2163" ]; then
  46. echo "<div>this version is broken. Please downgrade to a working version</div>"
  47. fi
  48. echo "<pre>"
  49. dmesg
  50. echo "</pre>"
  51. version_info "display_BAR"
  52. echo "</body>"
  53. echo "</html>"