Просмотр исходного кода

Update microcode.sh

Code refactoring
tteckster 1 год назад
Родитель
Сommit
0d6aac1201
1 измененных файлов с 19 добавлено и 9 удалено
  1. 19 9
      misc/microcode.sh

+ 19 - 9
misc/microcode.sh

@@ -4,15 +4,7 @@
 # License: MIT
 # License: MIT
 # https://github.com/tteck/Proxmox/raw/main/LICENSE
 # https://github.com/tteck/Proxmox/raw/main/LICENSE
 
 
-clear
-while true; do
-  read -p "Install the latest Processor Microcode (y/n)?" yn
-  case $yn in
-  [Yy]*) break ;;
-  [Nn]*) exit ;;
-  *) echo "Please answer yes or no." ;;
-  esac
-done
+function header_info {
 clear
 clear
 cat <<"EOF"
 cat <<"EOF"
     ____                                               __  ____                                __
     ____                                               __  ____                                __
@@ -22,6 +14,7 @@ cat <<"EOF"
 /_/   /_/   \____/\___/\___/____/____/\____/_/     /_/  /_/_/\___/_/   \____/\___/\____/\__,_/\___/
 /_/   /_/   \____/\___/\___/____/____/\____/_/     /_/  /_/_/\___/_/   \____/\___/\____/\__,_/\___/
 
 
 EOF
 EOF
+}
 
 
 RD=$(echo "\033[01;31m")
 RD=$(echo "\033[01;31m")
 YW=$(echo "\033[33m")
 YW=$(echo "\033[33m")
@@ -50,6 +43,23 @@ msg_error() {
   echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
   echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
 }
 }
 
 
+header_info
+current_microcode=$(dmesg | grep -o 'microcode updated early to revision [^,]*, date = [0-9\-]*')
+while true; do
+  if [ -z "${current_microcode}" ]; then
+    msg_error "Microcode update information not found."
+  else
+    msg_ok "Current ${current_microcode}"
+  fi
+  read -p "Install the latest Processor Microcode (y/n)?" yn
+  case $yn in
+  [Yy]*) break ;;
+  [Nn]*) exit ;;
+  *) echo "Please answer yes or no." ;;
+  esac
+done
+header_info
+
 intel() {
 intel() {
   if ! apt -qq list iucode-tool >/dev/null 2>&1; then
   if ! apt -qq list iucode-tool >/dev/null 2>&1; then
     msg_info "Installing iucode-tool: a tool for updating Intel processor microcode"
     msg_info "Installing iucode-tool: a tool for updating Intel processor microcode"