pve8-upgrade.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. header_info() {
  7. clear
  8. cat <<"EOF"
  9. ____ _ ____________ __ ______ __________ ___ ____ ______
  10. / __ \ | / / ____( __ ) / / / / __ \/ ____/ __ \/ | / __ \/ ____/
  11. / /_/ / | / / __/ / __ | / / / / /_/ / / __/ /_/ / /| | / / / / __/
  12. / ____/| |/ / /___/ /_/ / / /_/ / ____/ /_/ / _, _/ ___ |/ /_/ / /___
  13. /_/ |___/_____/\____/ \____/_/ \____/_/ |_/_/ |_/_____/_____/
  14. EOF
  15. }
  16. RD=$(echo "\033[01;31m")
  17. YW=$(echo "\033[33m")
  18. GN=$(echo "\033[1;92m")
  19. CL=$(echo "\033[m")
  20. BFR="\\r\\033[K"
  21. HOLD="-"
  22. CM="${GN}✓${CL}"
  23. CROSS="${RD}✗${CL}"
  24. set -euo pipefail
  25. shopt -s inherit_errexit nullglob
  26. msg_info() {
  27. local msg="$1"
  28. echo -ne " ${HOLD} ${YW}${msg}..."
  29. }
  30. msg_ok() {
  31. local msg="$1"
  32. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  33. }
  34. msg_error() {
  35. local msg="$1"
  36. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  37. }
  38. start_routines() {
  39. header_info
  40. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 SOURCES" "This will set the correct sources to update and install Proxmox VE 8." 10 58
  41. msg_info "Changing to Proxmox VE 8 Sources"
  42. cat <<EOF >/etc/apt/sources.list
  43. deb http://ftp.debian.org/debian bookworm main contrib
  44. deb http://ftp.debian.org/debian bookworm-updates main contrib
  45. deb http://security.debian.org/debian-security bookworm-security main contrib
  46. EOF
  47. msg_ok "Changed to Proxmox VE 8 Sources"
  48. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8-ENTERPRISE" "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription." 10 58
  49. msg_info "Disabling 'pve-enterprise' repository"
  50. cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
  51. # deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise
  52. EOF
  53. msg_ok "Disabled 'pve-enterprise' repository"
  54. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8-NO-SUBSCRIPTION" "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE." 10 58
  55. msg_info "Enabling 'pve-no-subscription' repository"
  56. cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
  57. deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription
  58. EOF
  59. msg_ok "Enabled 'pve-no-subscription' repository"
  60. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 CEPH PACKAGE REPOSITORIES" "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories." 10 58
  61. msg_info "Enabling 'ceph package repositories'"
  62. cat <<EOF >/etc/apt/sources.list.d/ceph.list
  63. # deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
  64. deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
  65. EOF
  66. msg_ok "Enabled 'ceph package repositories'"
  67. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 TEST" "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released (Disabled)." 10 58
  68. msg_info "Adding 'pvetest' repository and set disabled"
  69. cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
  70. # deb http://download.proxmox.com/debian/pve bookworm pvetest
  71. EOF
  72. msg_ok "Added 'pvetest' repository"
  73. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 UPDATE" "Updating to Proxmox VE 8" 10 58
  74. msg_info "Updating to Proxmox VE 8 (Patience)"
  75. apt-get update
  76. DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y
  77. msg_ok "Updated to Proxmox VE 8"
  78. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox VE 8 now? (recommended)" 11 58 2 \
  79. "yes" " " \
  80. "no" " " 3>&2 2>&1 1>&3)
  81. case $CHOICE in
  82. yes)
  83. msg_info "Rebooting Proxmox VE 8"
  84. sleep 2
  85. msg_ok "Completed Install Routines"
  86. reboot
  87. ;;
  88. no)
  89. msg_error "Selected no to Rebooting Proxmox VE 8 (Reboot recommended)"
  90. msg_ok "Completed Install Routines"
  91. ;;
  92. esac
  93. }
  94. header_info
  95. while true; do
  96. read -p "Start the Update to Proxmox VE 8 Script (y/n)?" yn
  97. case $yn in
  98. [Yy]*) break ;;
  99. [Nn]*) clear; exit ;;
  100. *) echo "Please answer yes or no." ;;
  101. esac
  102. done
  103. if ! command -v pveversion >/dev/null 2>&1; then
  104. header_info
  105. msg_error "\n No PVE Detected!\n"
  106. exit
  107. fi
  108. if ! pveversion | grep -Eq "pve-manager/(7\.4-(13|14|15|16|17))"; then
  109. header_info
  110. msg_error "This version of Proxmox Virtual Environment is not supported"
  111. echo -e " PVE Version 7.4-13 or higher is required."
  112. echo -e "\nExiting..."
  113. sleep 3
  114. exit
  115. fi
  116. start_routines