You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.2 KiB

  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-3.0+
  3. # Copyright (C) 2018, Martin Kepplinger <martink@posteo.de>
  4. RED='\033[0;31m'
  5. GREEN='\033[0;32m'
  6. NC='\033[0m'
  7. set -e
  8. usage()
  9. {
  10. echo "Skulls for the X230"
  11. echo " Run this script on the X230 directly."
  12. echo " It checks BIOS and hardware for relevant"
  13. echo " things if you plan to install Skulls"
  14. echo " please make sure dmidecode is installed"
  15. echo ""
  16. echo "Usage: $0"
  17. }
  18. args=$(getopt -o h -- "$@")
  19. if [ $? -ne 0 ] ; then
  20. usage
  21. exit 1
  22. fi
  23. eval set -- "$args"
  24. while [ $# -gt 0 ]
  25. do
  26. case "$1" in
  27. -h)
  28. usage
  29. exit 1
  30. ;;
  31. --)
  32. shift
  33. break
  34. ;;
  35. *)
  36. echo "Invalid option: $1"
  37. exit 1
  38. ;;
  39. esac
  40. shift
  41. done
  42. command -v dmidecode >/dev/null 2>&1 || { echo -e >&2 "${RED}Please install dmidecode and run as root.${NC}"; exit 1; }
  43. LAPTOP=$(dmidecode | grep -i x230 | sort -u)
  44. if [ -z "$LAPTOP" ] ; then
  45. echo "This is no Thinkpad X230. This script is useless then."
  46. exit 0
  47. fi
  48. BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2)
  49. if [[ $BIOS_VENDOR = *"coreboot"* ]] ; then
  50. echo "coreboot already intalled. This script is useless then."
  51. exit 0
  52. fi
  53. BIOS_VERSION=$(dmidecode -s bios-version | grep -o '[1-2].[0-7][0-9]')
  54. bios_major=$(echo "$BIOS_VERSION" | cut -d. -f1)
  55. bios_minor=$(echo "$BIOS_VERSION" | cut -d. -f2)
  56. if [ "${bios_minor}" -eq "72" ] ; then
  57. echo -e "${GREEN}latest BIOS version${NC} installed. Nothing to do."
  58. elif [ "${bios_minor}" -ge "60" ] ; then
  59. echo "installed BIOS version is ${bios_major}.${bios_minor}."
  60. echo "That's not the latest version, but the EC version is."
  61. echo "You may upgrade before installing coreboot if you want."
  62. else
  63. echo -e "The installed original BIOS is very old. ${RED}please upgrade${NC} before installing coreboot."
  64. fi
  65. echo "Please search for your SODIMM RAM and verify that it uses 1,5 Volts (not 1,35V):"
  66. dmidecode -t memory | grep Part | grep -v "Not Specified" | sort -u | cut -d':' -f2 | sed 's/ //'
  67. RAM_SPEC=$(dmidecode -t memory | grep Part | grep -v "Not Specified" | sort -u | cut -d':' -f2 | sed 's/ //')
  68. read -r -p "Open a browser and search for it? [y/N] " response
  69. case "$response" in
  70. [yY][eE][sS]|[yY])
  71. xdg-open "https://duckduckgo.com/?q=${RAM_SPEC}!"
  72. ;;
  73. *)
  74. exit 0
  75. ;;
  76. esac