Update edge-kernel.sh

update code
This commit is contained in:
tteckster 2022-12-20 02:14:26 -05:00 committed by GitHub
parent 13ac5e607f
commit e6ee476c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,9 @@ set -e
KERNEL_ON=$(uname -r) KERNEL_ON=$(uname -r)
PVE_KERNEL=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1) 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) EDGE_KERNEL=$(dpkg --list | grep 'kernel-.*-edge' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1)
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) }')
clear clear
while true; do while true; do
read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn
@ -14,7 +17,16 @@ while true; do
esac esac
done done
clear clear
function header_info {
cat <<"EOF"
____ _ ________ ______ __ __ __ __
/ __ \ | / / ____/ / ____/___/ /___ ____ / //_/__ _________ ___ / /____
/ /_/ / | / / __/ / __/ / __ / __ `/ _ \ / ,< / _ \/ ___/ __ \/ _ \/ / ___/
/ ____/| |/ / /___ / /___/ /_/ / /_/ / __/ / /| / __/ / / / / / __/ (__ )
/_/ |___/_____/ /_____/\__,_/\__, /\___/ /_/ |_\___/_/ /_/ /_/\___/_/____/
/____/
EOF
}
show_menu() { show_menu() {
normal=$(echo "\033[m") normal=$(echo "\033[m")
safe=$(echo "\033[32m") safe=$(echo "\033[32m")
@ -25,13 +37,13 @@ show_menu() {
proxmox-boot-tool kernel list proxmox-boot-tool kernel list
echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}" echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}"
printf "\n${menu}*********************************************${normal}\n" printf "\n${menu}*********************************************${normal}\n"
printf "${menu}**${number} 1)${normal} Install Proxmox Edge Kernel & Reboot\n" printf "${menu}**${number} 1)${normal} Install Proxmox Edge Kernel ${menu}${KER}${normal} & Reboot\n"
printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n" printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n"
printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n" printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n"
printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n" printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n"
printf "${menu}**${number} 5)${normal} Remove Proxmox Edge Kernel & Reboot\n" printf "${menu}**${number} 5)${normal} Remove All Current ${menu}${VER}*${normal} Proxmox Edge Kernels & Reboot\n"
printf "${menu}*********************************************${normal}\n" printf "${menu}*********************************************${normal}\n"
printf "Please choose an option from the menu and enter or ${fgred}x${normal} to exit." printf "Please choose an option from the menu, or ${fgred}x${normal} to exit."
read opt read opt
} }
option_picked() { option_picked() {
@ -41,6 +53,7 @@ option_picked() {
printf "${msgcolor}${message}${normal}\n" printf "${msgcolor}${message}${normal}\n"
} }
clear clear
header_info
show_menu show_menu
while [ "$opt" != "" ]; do while [ "$opt" != "" ]; do
if [ "$opt" = "" ]; then if [ "$opt" = "" ]; then
@ -62,7 +75,7 @@ while [ "$opt" != "" ]; do
curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add - curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add -
echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" >/etc/apt/sources.list.d/pve-edge-kernel.list
apt-get -y update apt-get -y update
apt-get -y install pve-kernel-6.0-edge apt-get -y install pve-kernel-${VER}-edge
reboot reboot
break break
;; ;;
@ -122,7 +135,7 @@ while [ "$opt" != "" ]; do
done done
clear clear
option_picked "Removing Proxmox Edge Kernel & Rebooting" option_picked "Removing Proxmox Edge Kernel & Rebooting"
apt-get purge -y ${EDGE_KERNEL} apt --purge remove -y pve-kernel-${VER}*edge pve-headers-${VER}*edge
rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list
proxmox-boot-tool kernel unpin proxmox-boot-tool kernel unpin
reboot reboot
@ -137,10 +150,11 @@ while [ "$opt" != "" ]; do
*) *)
clear clear
option_picked "Please choose an option from the menu" option_picked "Please choose an option from the menu"
header_info
show_menu show_menu
;; ;;
esac esac
fi fi
done done
header_info
show_menu show_menu