pbs3-upgrade.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 --backtitle "Proxmox VE Helper Scripts" --title "PBS 2 BACKUP" --menu "\nMake a backup of /etc/proxmox-backup to ensure that in the worst case, any relevant configuration can be recovered?" 14 58 2 \
  41. "yes" " " \
  42. "no" " " 3>&2 2>&1 1>&3)
  43. case $CHOICE in
  44. yes)
  45. msg_info "Backing up Proxmox Backup Server 2"
  46. tar czf "pbs2-etc-backup-$(date -I).tar.gz" -C "/etc" "proxmox-backup"
  47. msg_ok "Backed up Proxmox Backup Server 2"
  48. ;;
  49. no)
  50. msg_error "Selected no to Backing up Proxmox Backup Server 2"
  51. ;;
  52. esac
  53. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 3 SOURCES" --menu "This will set the correct sources to update and install Proxmox Backup Server 3.\n \nChange to Proxmox Backup Server 3 sources?" 14 58 2 \
  54. "yes" " " \
  55. "no" " " 3>&2 2>&1 1>&3)
  56. case $CHOICE in
  57. yes)
  58. msg_info "Changing to Proxmox Backup Server 3 Sources"
  59. cat <<EOF >/etc/apt/sources.list
  60. deb http://deb.debian.org/debian bookworm main contrib
  61. deb http://deb.debian.org/debian bookworm-updates main contrib
  62. deb http://security.debian.org/debian-security bookworm-security main contrib
  63. EOF
  64. msg_ok "Changed to Proxmox Backup Server 3 Sources"
  65. ;;
  66. no)
  67. msg_error "Selected no to Correcting Proxmox Backup Server 3 Sources"
  68. ;;
  69. esac
  70. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3-ENTERPRISE" --menu "The 'pbs-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pbs-enterprise' repository?" 14 58 2 \
  71. "yes" " " \
  72. "no" " " 3>&2 2>&1 1>&3)
  73. case $CHOICE in
  74. yes)
  75. msg_info "Disabling 'pbs-enterprise' repository"
  76. cat <<EOF >/etc/apt/sources.list.d/pbs-enterprise.list
  77. # deb https://enterprise.proxmox.com/debian/pbs bookworm pbs-enterprise
  78. EOF
  79. msg_ok "Disabled 'pbs-enterprise' repository"
  80. ;;
  81. no)
  82. msg_error "Selected no to Disabling 'pbs-enterprise' repository"
  83. ;;
  84. esac
  85. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3-NO-SUBSCRIPTION" --menu "The 'pbs-no-subscription' repository provides access to all of the open-source components of Proxmox Backup Server.\n \nEnable 'pbs-no-subscription' repository?" 14 58 2 \
  86. "yes" " " \
  87. "no" " " 3>&2 2>&1 1>&3)
  88. case $CHOICE in
  89. yes)
  90. msg_info "Enabling 'pbs-no-subscription' repository"
  91. cat <<EOF >/etc/apt/sources.list.d/pbs-install-repo.list
  92. deb http://download.proxmox.com/debian/pbs bookworm pbs-no-subscription
  93. EOF
  94. msg_ok "Enabled 'pbs-no-subscription' repository"
  95. ;;
  96. no)
  97. msg_error "Selected no to Enabling 'pbs-no-subscription' repository"
  98. ;;
  99. esac
  100. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3 TEST" --menu "The 'pbstest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pbstest' repository?" 14 58 2 \
  101. "yes" " " \
  102. "no" " " 3>&2 2>&1 1>&3)
  103. case $CHOICE in
  104. yes)
  105. msg_info "Adding 'pbstest' repository and set disabled"
  106. cat <<EOF >/etc/apt/sources.list.d/pbstest-for-beta.list
  107. # deb http://download.proxmox.com/debian/pbs bookworm pbstest
  108. EOF
  109. msg_ok "Added 'pbstest' repository"
  110. ;;
  111. no)
  112. msg_error "Selected no to Adding 'pbstest' repository"
  113. ;;
  114. esac
  115. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 3 UPDATE" --menu "\nUpdate to Proxmox Backup Server 3 now?" 11 58 2 \
  116. "yes" " " \
  117. "no" " " 3>&2 2>&1 1>&3)
  118. case $CHOICE in
  119. yes)
  120. msg_info "Updating to Proxmox Backup Server 3 (Patience)"
  121. apt-get update
  122. DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y
  123. msg_ok "Updated to Proxmox Backup Server 3"
  124. ;;
  125. no)
  126. msg_error "Selected no to Updating to Proxmox Backup Server 3"
  127. ;;
  128. esac
  129. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox Backup Server 3 now? (recommended)" 11 58 2 \
  130. "yes" " " \
  131. "no" " " 3>&2 2>&1 1>&3)
  132. case $CHOICE in
  133. yes)
  134. msg_info "Rebooting Proxmox Backup Server 3"
  135. sleep 2
  136. msg_ok "Completed Install Routines"
  137. reboot
  138. ;;
  139. no)
  140. msg_error "Selected no to Rebooting Proxmox Backup Server 3 (Reboot recommended)"
  141. msg_ok "Completed Install Routines"
  142. ;;
  143. esac
  144. }
  145. header_info
  146. while true; do
  147. read -p "Start the Update to Proxmox Backup Server 3 Script (y/n)?" yn
  148. case $yn in
  149. [Yy]*) break ;;
  150. [Nn]*) clear; exit ;;
  151. *) echo "Please answer yes or no." ;;
  152. esac
  153. done
  154. start_routines