post-pve-install.sh 4.3 KB

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