system-summary 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/sh
  2. . /lib/recovery-mode/l10n.sh
  3. if [ "$1" = "test" ]; then
  4. if [ "$2" = "mode" ]; then
  5. exit 2
  6. fi
  7. echo $(eval_gettext "System summary")
  8. exit 0
  9. fi
  10. # Get FS state
  11. if [ "$READONLY" = "true" ]; then
  12. fs_state=$(eval_gettext 'Read-only mode')
  13. else
  14. fs_state=$(eval_gettext 'Read/Write mode')
  15. fi
  16. # Check for existing connectivity
  17. net_state=$(eval_gettext 'none')
  18. ip route get 1.2.3.4 >/dev/null 2>&1 &&
  19. net_state=$(eval_gettext 'IP configured') &&
  20. grep ^nameserver -q /etc/resolv.conf &&
  21. net_state=$(eval_gettext 'IP and DNS configured')
  22. # Get CPU information
  23. cpu_count=$(ls -1 /sys/devices/system/cpu/ | grep "^cpu[0-9]*$" | wc -l)
  24. if [ -f /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ]; then
  25. cpu_freq=$(($(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) / 1000))
  26. else
  27. cpu_freq=0
  28. fi
  29. cpu_info="${cpu_count}x${cpu_freq}MHz"
  30. # Get RAID information
  31. if [ -n "$(grep md /proc/mdstat)" ]; then
  32. raid_state=$(cat /proc/mdstat | grep -v Personalities)
  33. else
  34. raid_state=$(eval_gettext 'No software RAID detected (mdstat)')
  35. fi
  36. # LVM
  37. if [ -z "$(which vgscan)" ]
  38. then
  39. lvm_state=$(eval_gettext 'No LVM detected (vgscan)')
  40. else
  41. if [ "$(id -u)" -ne 0 ]
  42. then
  43. lvm_state=$(eval_gettext 'Unknown (must be run as root)')
  44. else
  45. lvm_state="$(eval_gettext 'Physical Volumes:')"
  46. pvck >/dev/null 2>&1
  47. if [ $? -eq 0 ]; then
  48. lvm_state="$lvm_state $(eval_gettext 'ok (good)')"
  49. else
  50. lvm_state="$lvm_state $(eval_gettext 'not ok (BAD)')"
  51. fi
  52. lvm_state="$lvm_state
  53. $(eval_gettext 'Volume Groups:')"
  54. vgck >/dev/null 2>&1
  55. if [ $? -eq 0 ]; then
  56. lvm_state="$lvm_state $(eval_gettext 'ok (good)')"
  57. else
  58. lvm_state="$lvm_state $(eval_gettext 'not ok (BAD)')"
  59. fi
  60. fi
  61. fi
  62. # Get package system information
  63. if [ "$READONLY" = "true" ]; then
  64. apt_state=$(eval_gettext 'unknown (read-only filesystem)')
  65. elif [ "$(id -u)" -ne 0 ]; then
  66. apt_state=$(eval_gettext 'unknown (must be run as root)')
  67. else
  68. apt-get -qq --no-act check
  69. if [ $? -eq 0 ]; then
  70. apt_state=$(eval_gettext 'yes (good)')
  71. else
  72. apt_state=$(eval_gettext 'no (BAD)')
  73. fi
  74. fi
  75. msg="$(eval_gettext '(Use arrows/PageUp/PageDown keys to scroll and TAB key to select)')
  76. $(eval_gettext '=== General information ===')
  77. $(eval_gettext 'System mode:') $fs_state
  78. $(eval_gettext 'CPU information:') $cpu_info
  79. $(eval_gettext 'Network connectivity:') $net_state
  80. $(eval_gettext '=== Detailed disk usage ===')
  81. $(df -h 2>/dev/null)
  82. $(eval_gettext '=== Software RAID state ===')
  83. $raid_state
  84. $(eval_gettext '=== LVM state ===')
  85. $lvm_state
  86. $(eval_gettext '=== Detailed memory usage ===')
  87. $(free -m)
  88. $(eval_gettext '=== Detailed network configuration ===')
  89. $(ifconfig)
  90. $(eval_gettext '=== System database (APT) ===')
  91. $(eval_gettext 'Database is consistent:') $apt_state
  92. "
  93. whiptail --scrolltext --msgbox "$msg" 21 80 --title $(eval_gettext "System summary")
  94. exit 0