post-install-v3.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. echo -e "\e[1;33m This script will Perform Post Install Routines. PVE7 ONLY \e[0m"
  16. while true; do
  17. read -p "Start the PVE7 Post Install Script (y/n)?" yn
  18. case $yn in
  19. [Yy]* ) break;;
  20. [Nn]* ) exit;;
  21. * ) echo "Please answer yes or no.";;
  22. esac
  23. done
  24. if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then
  25. echo -e "This script requires Proxmox Virtual Environment 7.0 or greater"
  26. echo -e "Exiting..."
  27. sleep 2
  28. exit
  29. fi
  30. function header_info {
  31. echo -e "${RD}
  32. _______ ________ ______ _____ _ _____ _ _ _
  33. | __ \ \ / / ____|____ | | __ \ | | |_ _| | | | | |
  34. | |__) \ \ / /| |__ / / | |__) |__ ___| |_ | | _ __ ___| |_ __ _| | |
  35. | ___/ \ \/ / | __| v3 / / | ___/ _ \/ __| __| | | | _ \/ __| __/ _ | | |
  36. | | \ / | |____ / / | | | (_) \__ \ |_ _| |_| | | \__ \ || (_| | | |
  37. |_| \/ |______|/_/ |_| \___/|___/\__| |_____|_| |_|___/\__\__,_|_|_|
  38. ${CL}"
  39. }
  40. function msg_info() {
  41. local msg="$1"
  42. echo -ne " ${HOLD} ${YW}${msg}..."
  43. }
  44. function msg_ok() {
  45. local msg="$1"
  46. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  47. }
  48. clear
  49. header_info
  50. read -r -p "Disable Enterprise Repository? <Y/n> " prompt
  51. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  52. then
  53. msg_info "Disabling Enterprise Repository"
  54. sleep 2
  55. sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list
  56. msg_ok "Disabled Enterprise Repository"
  57. fi
  58. read -r -p "Add/Correct PVE7 Sources (sources.list)? <Y/n> " prompt
  59. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  60. then
  61. msg_info "Adding or Correcting PVE7 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 PVE7 Sources"
  69. fi
  70. read -r -p "Enable No-Subscription Repository? <Y/n> " prompt
  71. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  72. then
  73. msg_info "Enabling No-Subscription Repository"
  74. cat <<EOF >> /etc/apt/sources.list
  75. deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
  76. EOF
  77. sleep 2
  78. msg_ok "Enabled No-Subscription Repository"
  79. fi
  80. read -r -p "Add (Disabled) Beta/Test Repository? <Y/n> " prompt
  81. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  82. then
  83. msg_info "Adding Beta/Test Repository and set disabled"
  84. cat <<EOF >> /etc/apt/sources.list
  85. # deb http://download.proxmox.com/debian/pve bullseye pvetest
  86. EOF
  87. sleep 2
  88. msg_ok "Added Beta/Test Repository"
  89. fi
  90. read -r -p "Disable Subscription Nag? <Y/n> " prompt
  91. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
  92. then
  93. msg_info "Disabling Subscription Nag"
  94. 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
  95. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  96. msg_ok "Disabled Subscription Nag"
  97. fi
  98. msg_ok "Finished....Please Update Proxmox"