Proxmox/misc/edge-kernel.sh

161 lines
6.0 KiB
Bash
Raw Normal View History

2022-07-13 15:38:10 +00:00
#!/usr/bin/env bash
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)"
set -e
KERNEL_ON=$(uname -r)
2022-10-30 01:04:45 +00:00
PVE_KERNEL=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1)
EDGE_KERNEL=$(dpkg --list | grep 'kernel-.*-edge' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1)
2022-12-20 07:14:26 +00:00
VER=$(curl -s https://api.github.com/repos/fabianishere/pve-edge-kernel/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-9) }')
KER=$(curl -s https://api.github.com/repos/fabianishere/pve-edge-kernel/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-6) }')
2022-07-13 15:38:10 +00:00
clear
while true; do
2022-07-13 15:47:40 +00:00
read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn
2022-07-13 15:38:10 +00:00
case $yn in
2022-10-30 01:04:45 +00:00
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
2022-07-13 15:38:10 +00:00
esac
done
clear
2022-12-20 07:14:26 +00:00
function header_info {
cat <<"EOF"
____ _ ________ ______ __ __ __ __
/ __ \ | / / ____/ / ____/___/ /___ ____ / //_/__ _________ ___ / /____
/ /_/ / | / / __/ / __/ / __ / __ `/ _ \ / ,< / _ \/ ___/ __ \/ _ \/ / ___/
/ ____/| |/ / /___ / /___/ /_/ / /_/ / __/ / /| / __/ / / / / / __/ (__ )
/_/ |___/_____/ /_____/\__,_/\__, /\___/ /_/ |_\___/_/ /_/ /_/\___/_/____/
/____/
EOF
}
2022-10-30 01:04:45 +00:00
show_menu() {
normal=$(echo "\033[m")
safe=$(echo "\033[32m")
menu=$(echo "\033[36m")
number=$(echo "\033[33m")
bgred=$(echo "\033[41m")
fgred=$(echo "\033[31m")
2022-07-13 15:38:10 +00:00
proxmox-boot-tool kernel list
echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}"
printf "\n${menu}*********************************************${normal}\n"
2022-12-20 07:14:26 +00:00
printf "${menu}**${number} 1)${normal} Install Proxmox Edge Kernel ${menu}${KER}${normal} & Reboot\n"
2022-07-13 16:58:34 +00:00
printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n"
2022-07-13 15:38:10 +00:00
printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n"
2022-07-13 16:07:52 +00:00
printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n"
2022-12-20 07:14:26 +00:00
printf "${menu}**${number} 5)${normal} Remove All Current ${menu}${VER}*${normal} Proxmox Edge Kernels & Reboot\n"
2022-07-13 15:38:10 +00:00
printf "${menu}*********************************************${normal}\n"
2022-12-20 07:14:26 +00:00
printf "Please choose an option from the menu, or ${fgred}x${normal} to exit."
2022-07-13 15:38:10 +00:00
read opt
}
2022-10-30 01:04:45 +00:00
option_picked() {
msgcolor=$(echo "\033[01;31m")
normal=$(echo "\033[00;00m")
2022-07-13 15:38:10 +00:00
message=${@:-"${normal}Error: No message passed"}
printf "${msgcolor}${message}${normal}\n"
}
clear
2022-12-20 07:14:26 +00:00
header_info
2022-07-13 15:38:10 +00:00
show_menu
2022-11-13 18:38:37 +00:00
while [ "$opt" != "" ]; do
if [ "$opt" = "" ]; then
2022-10-30 01:04:45 +00:00
exit
2022-07-13 15:38:10 +00:00
else
2022-10-30 01:04:45 +00:00
case $opt in
1)
while true; do
read -p "Are you sure you want to Install Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
clear
option_picked "Installing Proxmox Edge Kernel & Rebooting"
2022-07-13 15:38:10 +00:00
apt-get install -y gnupg
curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add -
2022-10-30 01:04:45 +00:00
echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list
2022-07-13 15:38:10 +00:00
apt-get -y update
2022-12-20 07:14:26 +00:00
apt-get -y install pve-kernel-${VER}-edge
2022-07-13 15:38:10 +00:00
reboot
2022-10-30 01:04:45 +00:00
break
;;
2)
while true; do
read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
clear
option_picked "Switching to Proxmox VE 7 Kernel & Rebooting"
2022-07-13 15:38:10 +00:00
proxmox-boot-tool kernel pin ${PVE_KERNEL}
reboot
2022-10-30 01:04:45 +00:00
break
;;
3)
while true; do
read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
clear
option_picked "Switching to Proxmox Edge Kernel & Rebooting"
2022-07-13 15:38:10 +00:00
proxmox-boot-tool kernel pin ${EDGE_KERNEL}
reboot
2022-10-30 01:04:45 +00:00
break
;;
4)
while true; do
read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
clear
option_picked "Unpinning Current Kernel"
2022-07-13 16:07:52 +00:00
proxmox-boot-tool kernel unpin
2022-10-30 01:04:45 +00:00
clear
break
;;
5)
while true; do
read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
esac
done
clear
option_picked "Removing Proxmox Edge Kernel & Rebooting"
2022-12-20 07:14:26 +00:00
apt --purge remove -y pve-kernel-${VER}*edge pve-headers-${VER}*edge
2022-07-13 15:38:10 +00:00
rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list
proxmox-boot-tool kernel unpin
reboot
2022-10-30 01:04:45 +00:00
break
;;
x)
exit
;;
\n)
exit
;;
*)
clear
option_picked "Please choose an option from the menu"
2022-12-20 07:14:26 +00:00
header_info
2022-10-30 01:04:45 +00:00
show_menu
;;
esac
2022-07-13 15:38:10 +00:00
fi
2022-10-30 01:04:45 +00:00
done
2022-12-20 07:14:26 +00:00
header_info
2022-07-13 15:38:10 +00:00
show_menu