post-pbs-install.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env bash -ex
  2. set -euo pipefail
  3. shopt -s inherit_errexit nullglob
  4. YW=$(echo "\033[33m")
  5. BL=$(echo "\033[36m")
  6. RD=$(echo "\033[01;31m")
  7. BGN=$(echo "\033[4;92m")
  8. GN=$(echo "\033[1;92m")
  9. DGN=$(echo "\033[32m")
  10. CL=$(echo "\033[m")
  11. BFR="\\r\\033[K"
  12. HOLD="-"
  13. CM="${GN}✓${CL}"
  14. CROSS="${RD}✗${CL}"
  15. clear
  16. echo -e "${BL}This script will Perform Post Install Routines.${CL}"
  17. while true; do
  18. read -p "Start the PBS Post Install Script (y/n)?" yn
  19. case $yn in
  20. [Yy]*) break ;;
  21. [Nn]*) exit ;;
  22. *) echo "Please answer yes or no." ;;
  23. esac
  24. done
  25. if command -v pveversion >/dev/null 2>&1; then
  26. echo -e "\n🛑 PVE Detected, Wrong Script!\n"
  27. exit 1
  28. fi
  29. function header_info {
  30. cat <<"EOF"
  31. ____ ____ _____ ____ __ ____ __ ____
  32. / __ \/ __ ) ___/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
  33. / /_/ / __ \__ \ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
  34. / ____/ /_/ /__/ / / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
  35. /_/ /_____/____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
  36. EOF
  37. }
  38. function msg_info() {
  39. local msg="$1"
  40. echo -ne " ${HOLD} ${YW}${msg}..."
  41. }
  42. function msg_ok() {
  43. local msg="$1"
  44. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  45. }
  46. clear
  47. header_info
  48. read -r -p "Disable Enterprise Repository? <y/N> " prompt
  49. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  50. msg_info "Disabling Enterprise Repository"
  51. sleep 2
  52. sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pbs-enterprise.list
  53. msg_ok "Disabled Enterprise Repository"
  54. fi
  55. read -r -p "Add/Correct PBS Sources (sources.list)? <y/N> " prompt
  56. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  57. msg_info "Adding or Correcting PBS Sources"
  58. cat <<EOF >/etc/apt/sources.list
  59. deb http://ftp.debian.org/debian bullseye main contrib
  60. deb http://ftp.debian.org/debian bullseye-updates main contrib
  61. deb http://security.debian.org/debian-security bullseye-security main contrib
  62. EOF
  63. sleep 2
  64. msg_ok "Added or Corrected PBS Sources"
  65. fi
  66. read -r -p "Enable No-Subscription Repository? <y/N> " prompt
  67. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  68. msg_info "Enabling No-Subscription Repository"
  69. cat <<EOF >>/etc/apt/sources.list
  70. deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription
  71. EOF
  72. sleep 2
  73. msg_ok "Enabled No-Subscription Repository"
  74. fi
  75. read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt
  76. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  77. msg_info "Adding Beta/Test Repository and set disabled"
  78. cat <<EOF >>/etc/apt/sources.list
  79. # deb http://download.proxmox.com/debian/pbs bullseye pbstest
  80. EOF
  81. sleep 2
  82. msg_ok "Added Beta/Test Repository"
  83. fi
  84. read -r -p "Disable Subscription Nag? <y/N> " prompt
  85. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  86. msg_info "Disabling Subscription Nag"
  87. 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
  88. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  89. msg_ok "Disabled Subscription Nag"
  90. fi
  91. read -r -p "Update Proxmox Backup Server now? <y/N> " prompt
  92. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  93. msg_info "Updating Proxmox Backup Server (Patience)"
  94. apt-get update &>/dev/null
  95. apt-get -y dist-upgrade &>/dev/null
  96. msg_ok "Updated Proxmox Backup Server (⚠ Reboot Recommended)"
  97. fi
  98. read -r -p "Reboot Proxmox Backup Server now? <y/N> " prompt
  99. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  100. msg_info "Rebooting Proxmox Backup Server"
  101. sleep 2
  102. msg_ok "Completed Post Install Routines"
  103. reboot
  104. fi
  105. sleep 2
  106. msg_ok "Completed Post Install Routines"