post-pbs-install.sh 3.9 KB

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