pve8-install.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. CHOICE=$(whiptail --title "PVE8 SOURCES" --menu "This will set the correct sources to update and install Proxmox VE 8.\n \nChange to Proxmox VE 8 sources?" 14 58 2 \
  41. "yes" " " \
  42. "no" " " 3>&2 2>&1 1>&3)
  43. case $CHOICE in
  44. yes)
  45. msg_info "Changing to Proxmox VE 8 Sources"
  46. cat <<EOF >/etc/apt/sources.list
  47. deb http://ftp.debian.org/debian bookworm main contrib
  48. deb http://ftp.debian.org/debian bookworm-updates main contrib
  49. deb http://security.debian.org/debian-security bookworm-security main contrib
  50. EOF
  51. msg_ok "Changed to Proxmox VE 8 Sources"
  52. ;;
  53. no)
  54. msg_error "Selected no to Correcting Proxmox VE 8 Sources"
  55. ;;
  56. esac
  57. CHOICE=$(whiptail --title "PVE8-ENTERPRISE" --menu "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pve-enterprise' repository?" 14 58 2 \
  58. "yes" " " \
  59. "no" " " 3>&2 2>&1 1>&3)
  60. case $CHOICE in
  61. yes)
  62. msg_info "Disabling 'pve-enterprise' repository"
  63. cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
  64. # deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise
  65. EOF
  66. msg_ok "Disabled 'pve-enterprise' repository"
  67. ;;
  68. no)
  69. msg_error "Selected no to Disabling 'pve-enterprise' repository"
  70. ;;
  71. esac
  72. CHOICE=$(whiptail --title "PVE8-NO-SUBSCRIPTION" --menu "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE.\n \nEnable 'pve-no-subscription' repository?" 14 58 2 \
  73. "yes" " " \
  74. "no" " " 3>&2 2>&1 1>&3)
  75. case $CHOICE in
  76. yes)
  77. msg_info "Enabling 'pve-no-subscription' repository"
  78. cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
  79. # deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription
  80. EOF
  81. msg_ok "Enabled 'pve-no-subscription' repository"
  82. ;;
  83. no)
  84. msg_error "Selected no to Enabling 'pve-no-subscription' repository"
  85. ;;
  86. esac
  87. CHOICE=$(whiptail --title "PVE8 CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories.\n \nEnable 'ceph package repositories?" 14 58 2 \
  88. "yes" " " \
  89. "no" " " 3>&2 2>&1 1>&3)
  90. case $CHOICE in
  91. yes)
  92. msg_info "Enabling 'ceph package repositories'"
  93. cat <<EOF >/etc/apt/sources.list.d/ceph.list
  94. # deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
  95. deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
  96. EOF
  97. msg_ok "Enabled 'ceph package repositories'"
  98. ;;
  99. no)
  100. msg_error "Selected no to Enabling 'ceph package repositories'"
  101. ;;
  102. esac
  103. CHOICE=$(whiptail --title "PVE8 TEST" --menu "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd 'pvetest' repository?" 14 58 2 \
  104. "yes" " " \
  105. "no" " " 3>&2 2>&1 1>&3)
  106. case $CHOICE in
  107. yes)
  108. msg_info "Adding 'pvetest' repository and set disabled"
  109. cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
  110. deb http://download.proxmox.com/debian/pve bookworm pvetest
  111. EOF
  112. msg_ok "Added 'pvetest' repository"
  113. ;;
  114. no)
  115. msg_error "Selected no to Adding 'pvetest' repository"
  116. ;;
  117. esac
  118. CHOICE=$(whiptail --title "PVE8 UPDATE" --menu "\nUpdate to Proxmox VE 8 now?" 11 58 2 \
  119. "yes" " " \
  120. "no" " " 3>&2 2>&1 1>&3)
  121. case $CHOICE in
  122. yes)
  123. msg_info "Updating to Proxmox VE 8 (Patience)"
  124. apt-get update
  125. DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y
  126. msg_ok "Updated to Proxmox VE 8"
  127. ;;
  128. no)
  129. msg_error "Selected no to Updating to Proxmox VE 8"
  130. ;;
  131. esac
  132. CHOICE=$(whiptail --title "REBOOT" --menu "\nReboot Proxmox VE 8 now? (recommended)" 11 58 2 \
  133. "yes" " " \
  134. "no" " " 3>&2 2>&1 1>&3)
  135. case $CHOICE in
  136. yes)
  137. msg_info "Rebooting Proxmox VE 8"
  138. sleep 2
  139. msg_ok "Completed Install Routines"
  140. reboot
  141. ;;
  142. no)
  143. msg_error "Selected no to Rebooting Proxmox VE 8 (Reboot recommended)"
  144. msg_ok "Completed Install Routines"
  145. ;;
  146. esac
  147. }
  148. header_info
  149. while true; do
  150. read -p "Start the Update to Proxmox VE 8 Script (y/n)?" yn
  151. case $yn in
  152. [Yy]*) break ;;
  153. [Nn]*) clear; exit ;;
  154. *) echo "Please answer yes or no." ;;
  155. esac
  156. done
  157. if ! command -v pveversion >/dev/null 2>&1; then
  158. header_info
  159. msg_error "\n No PVE Detected!\n"
  160. exit
  161. fi
  162. if [ $(pveversion | grep "pve-manager/7.4-13" | wc -l) -ne 1 ]; then
  163. header_info
  164. msg_error "This version of Proxmox Virtual Environment is not supported"
  165. echo -e " Requires PVE Version: 7.4-13"
  166. echo -e "\nExiting..."
  167. sleep 3
  168. exit
  169. fi
  170. start_routines