post-pbs-install.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
  41. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS SOURCES" --menu "This will set the correct sources to update and install Proxmox Backup Server.\n \nChange to Proxmox Backup Server sources?" 14 58 2 \
  42. "yes" " " \
  43. "no" " " 3>&2 2>&1 1>&3)
  44. case $CHOICE in
  45. yes)
  46. msg_info "Changing to Proxmox Backup Server Sources"
  47. cat <<EOF >/etc/apt/sources.list
  48. deb http://deb.debian.org/debian ${VERSION} main contrib
  49. deb http://deb.debian.org/debian ${VERSION}-updates main contrib
  50. deb http://security.debian.org/debian-security ${VERSION}-security main contrib
  51. EOF
  52. msg_ok "Changed to Proxmox Backup Server Sources"
  53. ;;
  54. no)
  55. msg_error "Selected no to Correcting Proxmox Backup Server Sources"
  56. ;;
  57. esac
  58. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS-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 \
  59. "yes" " " \
  60. "no" " " 3>&2 2>&1 1>&3)
  61. case $CHOICE in
  62. yes)
  63. msg_info "Disabling 'pbs-enterprise' repository"
  64. cat <<EOF >/etc/apt/sources.list.d/pbs-enterprise.list
  65. # deb https://enterprise.proxmox.com/debian/pbs ${VERSION} pbs-enterprise
  66. EOF
  67. msg_ok "Disabled 'pbs-enterprise' repository"
  68. ;;
  69. no)
  70. msg_error "Selected no to Disabling 'pbs-enterprise' repository"
  71. ;;
  72. esac
  73. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS-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 \
  74. "yes" " " \
  75. "no" " " 3>&2 2>&1 1>&3)
  76. case $CHOICE in
  77. yes)
  78. msg_info "Enabling 'pbs-no-subscription' repository"
  79. cat <<EOF >/etc/apt/sources.list.d/pbs-install-repo.list
  80. deb http://download.proxmox.com/debian/pbs ${VERSION} pbs-no-subscription
  81. EOF
  82. msg_ok "Enabled 'pbs-no-subscription' repository"
  83. ;;
  84. no)
  85. msg_error "Selected no to Enabling 'pbs-no-subscription' repository"
  86. ;;
  87. esac
  88. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 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 \
  89. "yes" " " \
  90. "no" " " 3>&2 2>&1 1>&3)
  91. case $CHOICE in
  92. yes)
  93. msg_info "Adding 'pbstest' repository and set disabled"
  94. cat <<EOF >/etc/apt/sources.list.d/pbstest-for-beta.list
  95. # deb http://download.proxmox.com/debian/pbs ${VERSION} pbstest
  96. EOF
  97. msg_ok "Added 'pbstest' repository"
  98. ;;
  99. no)
  100. msg_error "Selected no to Adding 'pbstest' repository"
  101. ;;
  102. esac
  103. if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then
  104. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \
  105. "yes" " " \
  106. "no" " " 3>&2 2>&1 1>&3)
  107. case $CHOICE in
  108. yes)
  109. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
  110. msg_info "Disabling subscription nag"
  111. echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
  112. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  113. msg_ok "Disabled subscription nag (Delete browser cache)"
  114. ;;
  115. no)
  116. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
  117. msg_error "Selected no to Disabling subscription nag"
  118. ;;
  119. esac
  120. fi
  121. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox Backup Server now?" 11 58 2 \
  122. "yes" " " \
  123. "no" " " 3>&2 2>&1 1>&3)
  124. case $CHOICE in
  125. yes)
  126. msg_info "Updating Proxmox Backup Server (Patience)"
  127. apt-get update &>/dev/null
  128. apt-get -y dist-upgrade &>/dev/null
  129. msg_ok "Updated Proxmox Backup Server"
  130. ;;
  131. no)
  132. msg_error "Selected no to Updating Proxmox Backup Server"
  133. ;;
  134. esac
  135. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox Backup Server now? (recommended)" 11 58 2 \
  136. "yes" " " \
  137. "no" " " 3>&2 2>&1 1>&3)
  138. case $CHOICE in
  139. yes)
  140. msg_info "Rebooting Proxmox Backup Server"
  141. sleep 2
  142. msg_ok "Completed Post Install Routines"
  143. reboot
  144. ;;
  145. no)
  146. msg_error "Selected no to Rebooting Proxmox Backup Server (Reboot recommended)"
  147. msg_ok "Completed Post Install Routines"
  148. ;;
  149. esac
  150. }
  151. header_info
  152. echo -e "\nThis script will Perform Post Install Routines.\n"
  153. while true; do
  154. read -p "Start the Proxmox Backup Server Post Install Script (y/n)?" yn
  155. case $yn in
  156. [Yy]*) break ;;
  157. [Nn]*) clear; exit ;;
  158. *) echo "Please answer yes or no." ;;
  159. esac
  160. done
  161. if command -v pveversion >/dev/null 2>&1; then
  162. echo -e "\n🛑 PVE Detected, Wrong Script!\n"
  163. exit 1
  164. fi
  165. start_routines