microcode.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. clear
  7. while true; do
  8. read -p "Install the latest Intel Processor Microcode (y/n)?" yn
  9. case $yn in
  10. [Yy]*) break ;;
  11. [Nn]*) exit ;;
  12. *) echo "Please answer yes or no." ;;
  13. esac
  14. done
  15. clear
  16. cat <<"EOF"
  17. ____ __ __ __ ____ __
  18. / _/___ / /____ / / / |/ (_)_____________ _________ ____/ /__
  19. / // __ \/ __/ _ \/ / / /|_/ / / ___/ ___/ __ \/ ___/ __ \/ __ / _ \
  20. _/ // / / / /_/ __/ / / / / / / /__/ / / /_/ / /__/ /_/ / /_/ / __/
  21. /___/_/ /_/\__/\___/_/ /_/ /_/_/\___/_/ \____/\___/\____/\__,_/\___/
  22. EOF
  23. RD=$(echo "\033[01;31m")
  24. YW=$(echo "\033[33m")
  25. GN=$(echo "\033[1;92m")
  26. CL=$(echo "\033[m")
  27. BFR="\\r\\033[K"
  28. HOLD="-"
  29. CM="${GN}✓${CL}"
  30. CROSS="${RD}✗${CL}"
  31. set -euo pipefail
  32. shopt -s inherit_errexit nullglob
  33. msg_info() {
  34. local msg="$1"
  35. echo -ne " ${HOLD} ${YW}${msg}..."
  36. }
  37. msg_ok() {
  38. local msg="$1"
  39. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  40. }
  41. msg_error() {
  42. local msg="$1"
  43. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  44. }
  45. msg_info "Checking CPU Vendor"
  46. cpu=$(lscpu | grep -oP 'Vendor ID:\s*\K\S+')
  47. if [ "$cpu" == "GenuineIntel" ]; then
  48. msg_ok "${cpu} was detected"
  49. else
  50. msg_error "${cpu} is not supported"
  51. exit
  52. fi
  53. msg_info "Installing iucode-tool: a tool for updating Intel processor microcode"
  54. apt-get install -y iucode-tool &>/dev/null
  55. msg_ok "Installed iucode-tool"
  56. msg_info "Downloading the latest Intel Processor Microcode Package for Linux"
  57. release=$(curl -s https://api.github.com/repos/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/latest | awk -F'"' '/tag_name/{print $4}' | tr -cd '[:digit:]')
  58. wget -q http://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/intel-microcode_3.${release}.1_amd64.deb
  59. msg_ok "Downloaded the latest Intel Processor Microcode Package"
  60. msg_info "Installing the Intel Processor Microcode (Patience)"
  61. dpkg -i intel-microcode_3.${release}.1_amd64.deb &>/dev/null
  62. msg_ok "Installed the Intel Processor Microcode"
  63. msg_info "Cleaning up"
  64. rm intel-microcode_3.${release}.1_amd64.deb
  65. msg_ok "Cleaned"
  66. echo -e "\n To apply the settings, the system will need to be rebooted.\n"