2023-05-01 23:50:43 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2023 tteck
|
|
|
|
# Author: tteck (tteckster)
|
|
|
|
# License: MIT
|
|
|
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
|
|
|
|
2023-08-10 12:51:20 +02:00
|
|
|
function header_info {
|
2023-05-01 23:50:43 +02:00
|
|
|
clear
|
|
|
|
cat <<"EOF"
|
2023-05-08 15:13:34 +02:00
|
|
|
____ __ ____ __
|
|
|
|
/ __ \_________ ________ ______________ _____ / |/ (_)_____________ _________ ____/ /__
|
|
|
|
/ /_/ / ___/ __ \/ ___/ _ \/ ___/ ___/ __ \/ ___/ / /|_/ / / ___/ ___/ __ \/ ___/ __ \/ __ / _ \
|
|
|
|
/ ____/ / / /_/ / /__/ __(__ |__ ) /_/ / / / / / / / /__/ / / /_/ / /__/ /_/ / /_/ / __/
|
|
|
|
/_/ /_/ \____/\___/\___/____/____/\____/_/ /_/ /_/_/\___/_/ \____/\___/\____/\__,_/\___/
|
2023-05-01 23:50:43 +02:00
|
|
|
|
|
|
|
EOF
|
2023-08-10 12:51:20 +02:00
|
|
|
}
|
2023-05-01 23:50:43 +02:00
|
|
|
|
2023-05-07 22:10:15 +02:00
|
|
|
RD=$(echo "\033[01;31m")
|
2023-05-01 23:50:43 +02:00
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
GN=$(echo "\033[1;92m")
|
|
|
|
CL=$(echo "\033[m")
|
|
|
|
BFR="\\r\\033[K"
|
|
|
|
HOLD="-"
|
|
|
|
CM="${GN}✓${CL}"
|
2023-05-07 22:10:15 +02:00
|
|
|
CROSS="${RD}✗${CL}"
|
2023-05-01 23:50:43 +02:00
|
|
|
|
|
|
|
msg_info() {
|
2023-05-08 15:13:34 +02:00
|
|
|
local msg="$1"
|
|
|
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
2023-05-01 23:50:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_ok() {
|
2023-05-08 15:13:34 +02:00
|
|
|
local msg="$1"
|
|
|
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
2023-05-01 23:50:43 +02:00
|
|
|
}
|
|
|
|
|
2023-05-07 22:10:15 +02:00
|
|
|
msg_error() {
|
|
|
|
local msg="$1"
|
|
|
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
|
|
|
}
|
|
|
|
|
2023-08-10 12:51:20 +02:00
|
|
|
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
|
|
|
|
|
2023-05-08 15:13:34 +02:00
|
|
|
intel() {
|
2023-08-11 17:46:54 +02:00
|
|
|
if ! dpkg -s iucode-tool >/dev/null 2>&1; then
|
2023-08-10 12:11:06 +02:00
|
|
|
msg_info "Installing iucode-tool: a tool for updating Intel processor microcode"
|
|
|
|
apt-get install -y iucode-tool &>/dev/null
|
|
|
|
msg_ok "Installed iucode-tool"
|
|
|
|
else
|
|
|
|
msg_ok "Intel iucode-tool is already installed"
|
|
|
|
fi
|
2023-05-08 20:24:29 +02:00
|
|
|
|
|
|
|
msg_info "Downloading the latest Intel Processor Microcode Package for Linux"
|
2023-08-10 02:08:56 +02:00
|
|
|
wget -q http://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/intel-microcode_3.20230808.1_amd64.deb
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Downloaded the latest Intel Processor Microcode Package"
|
|
|
|
|
|
|
|
msg_info "Installing the Intel Processor Microcode (Patience)"
|
2023-08-10 02:08:56 +02:00
|
|
|
dpkg -i intel-microcode_3.20230808.1_amd64.deb &>/dev/null
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Installed the Intel Processor Microcode"
|
|
|
|
|
|
|
|
msg_info "Cleaning up"
|
2023-08-10 02:08:56 +02:00
|
|
|
rm intel-microcode_3.20230808.1_amd64.deb
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Cleaned"
|
|
|
|
|
|
|
|
echo -e "\n To apply the changes, the system will need to be rebooted.\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
amd() {
|
|
|
|
msg_info "Downloading the latest AMD Processor Microcode Package for Linux"
|
2023-08-10 23:33:46 +02:00
|
|
|
wget -q http://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode/amd64-microcode_3.20230808.1.1_amd64.deb
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Downloaded the latest AMD Processor Microcode Package"
|
|
|
|
|
|
|
|
msg_info "Installing the AMD Processor Microcode (Patience)"
|
2023-08-10 23:33:46 +02:00
|
|
|
dpkg -i amd64-microcode_3.20230808.1.1_amd64.deb &>/dev/null
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Installed the AMD Processor Microcode"
|
|
|
|
|
|
|
|
msg_info "Cleaning up"
|
2023-08-10 23:33:46 +02:00
|
|
|
rm amd64-microcode_3.20230808.1.1_amd64.deb
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_ok "Cleaned"
|
|
|
|
|
|
|
|
echo -e "\n To apply the changes, the system will need to be rebooted.\n"
|
|
|
|
}
|
|
|
|
|
2023-06-20 21:54:38 +02:00
|
|
|
if ! command -v pveversion >/dev/null 2>&1; then
|
|
|
|
header_info
|
|
|
|
msg_error "\n No PVE Detected!\n"
|
2023-05-08 15:13:34 +02:00
|
|
|
exit
|
|
|
|
fi
|
2023-05-07 22:10:15 +02:00
|
|
|
msg_info "Checking CPU Vendor"
|
2023-06-20 22:08:58 +02:00
|
|
|
cpu=$(lscpu | grep -oP 'Vendor ID:\s*\K\S+' | head -n 1)
|
2023-05-07 22:10:15 +02:00
|
|
|
if [ "$cpu" == "GenuineIntel" ]; then
|
|
|
|
msg_ok "${cpu} was detected"
|
2023-05-08 15:13:34 +02:00
|
|
|
intel
|
|
|
|
elif [ "$cpu" == "AuthenticAMD" ]; then
|
|
|
|
msg_ok "${cpu} was detected"
|
|
|
|
amd
|
2023-05-07 22:10:15 +02:00
|
|
|
else
|
2023-05-08 15:13:34 +02:00
|
|
|
msg_error "${cpu} is not supported"
|
2023-05-07 22:10:15 +02:00
|
|
|
exit
|
2023-05-08 15:13:34 +02:00
|
|
|
fi
|