post-install.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 PVE7 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🛑 No PVE Detected, Wrong Script!\n"
  27. exit 1
  28. fi
  29. if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then
  30. echo -e "\n${RD}⚠ This version of Proxmox Virtual Environment is not supported"
  31. echo -e "Requires PVE Version: 7.XX${CL}"
  32. echo -e "\nExiting..."
  33. sleep 3
  34. exit
  35. fi
  36. function header_info {
  37. echo -e "${RD}
  38. ____ _ _____________ ____ __ ____ __ ____
  39. / __ \ | / / ____/__ / / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
  40. / /_/ / | / / __/ / / / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ / / /
  41. / ____/| |/ / /___ / / / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
  42. /_/ |___/_____/ /_/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
  43. ${CL}"
  44. }
  45. function msg_info() {
  46. local msg="$1"
  47. echo -ne " ${HOLD} ${YW}${msg}..."
  48. }
  49. function msg_ok() {
  50. local msg="$1"
  51. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  52. }
  53. clear
  54. header_info
  55. read -r -p "Disable Enterprise Repository? <y/N> " prompt
  56. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  57. 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" ]]
  65. then
  66. msg_info "Adding or Correcting PVE7 Sources"
  67. cat <<EOF > /etc/apt/sources.list
  68. deb http://ftp.debian.org/debian bullseye main contrib
  69. deb http://ftp.debian.org/debian bullseye-updates main contrib
  70. deb http://security.debian.org/debian-security bullseye-security main contrib
  71. EOF
  72. sleep 2
  73. msg_ok "Added or Corrected PVE7 Sources"
  74. fi
  75. read -r -p "Enable No-Subscription Repository? <y/N> " prompt
  76. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  77. then
  78. msg_info "Enabling No-Subscription Repository"
  79. cat <<EOF >> /etc/apt/sources.list
  80. deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
  81. EOF
  82. sleep 2
  83. msg_ok "Enabled No-Subscription Repository"
  84. fi
  85. read -r -p "Add (Disabled) Beta/Test Repository? <y/N> " prompt
  86. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  87. then
  88. msg_info "Adding Beta/Test Repository and set disabled"
  89. cat <<EOF >> /etc/apt/sources.list
  90. # deb http://download.proxmox.com/debian/pve bullseye pvetest
  91. EOF
  92. sleep 2
  93. msg_ok "Added Beta/Test Repository"
  94. fi
  95. read -r -p "Disable Subscription Nag? <y/N> " prompt
  96. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  97. then
  98. msg_info "Disabling Subscription Nag"
  99. 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
  100. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  101. msg_ok "Disabled Subscription Nag"
  102. fi
  103. read -r -p "Update Proxmox VE 7 now? <y/N> " prompt
  104. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  105. then
  106. msg_info "Updating Proxmox VE 7 (Patience)"
  107. apt-get update &>/dev/null
  108. apt-get -y dist-upgrade &>/dev/null
  109. msg_ok "Updated Proxmox VE 7 (⚠ Reboot Recommended)"
  110. fi
  111. read -r -p "Reboot Proxmox VE 7 now? <y/N> " prompt
  112. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  113. then
  114. msg_info "Rebooting Proxmox VE 7"
  115. sleep 2
  116. msg_ok "Completed Post Install Routines"
  117. reboot
  118. fi
  119. sleep 2
  120. msg_ok "Completed Post Install Routines"