post-pve-install.sh 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. header_info() {
  7. clear
  8. cat <<"EOF"
  9. ____ _ ________ ____ __ ____ __ ____
  10. / __ \ | / / ____/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
  11. / /_/ / | / / __/ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
  12. / ____/| |/ / /___ / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
  13. /_/ |___/_____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
  14. EOF
  15. }
  16. RD=$(echo "\033[01;31m")
  17. YW=$(echo "\033[33m")
  18. GN=$(echo "\033[1;92m")
  19. CL=$(echo "\033[m")
  20. BFR="\\r\\033[K"
  21. HOLD="-"
  22. CM="${GN}✓${CL}"
  23. CROSS="${RD}✗${CL}"
  24. set -euo pipefail
  25. shopt -s inherit_errexit nullglob
  26. msg_info() {
  27. local msg="$1"
  28. echo -ne " ${HOLD} ${YW}${msg}..."
  29. }
  30. msg_ok() {
  31. local msg="$1"
  32. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  33. }
  34. msg_error() {
  35. local msg="$1"
  36. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  37. }
  38. start_routines() {
  39. header_info
  40. VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
  41. if lscpu | grep -qP 'Vendor ID:.*GenuineIntel' && lscpu | grep -qP 'Model name:.*N' && [[ "$VERSION" == "bullseye" ]]; then
  42. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "N-SERIES PROCESSOR DETECTED" "To ensure compatibility with Proxmox VE on systems equipped with N-series processors, it is recommended to install Proxmox Virtual Environment 8" 10 58
  43. fi
  44. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SOURCES" --menu "The package manager will use the correct sources to update and install packages on your Proxmox VE server.\n \nCorrect Proxmox VE sources?" 14 58 2 \
  45. "yes" " " \
  46. "no" " " 3>&2 2>&1 1>&3)
  47. case $CHOICE in
  48. yes)
  49. msg_info "Correcting Proxmox VE Sources"
  50. cat <<EOF >/etc/apt/sources.list
  51. deb http://ftp.debian.org/debian ${VERSION} main contrib
  52. deb http://ftp.debian.org/debian ${VERSION}-updates main contrib
  53. deb http://security.debian.org/debian-security ${VERSION}-security main contrib
  54. EOF
  55. msg_ok "Corrected Proxmox VE Sources"
  56. ;;
  57. no)
  58. msg_error "Selected no to Correcting Proxmox VE Sources"
  59. ;;
  60. esac
  61. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVE-ENTERPRISE" --menu "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pve-enterprise' repository?" 14 58 2 \
  62. "yes" " " \
  63. "no" " " 3>&2 2>&1 1>&3)
  64. case $CHOICE in
  65. yes)
  66. msg_info "Disabling 'pve-enterprise' repository"
  67. cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
  68. # deb https://enterprise.proxmox.com/debian/pve ${VERSION} pve-enterprise
  69. EOF
  70. msg_ok "Disabled 'pve-enterprise' repository"
  71. ;;
  72. no)
  73. msg_error "Selected no to Disabling 'pve-enterprise' repository"
  74. ;;
  75. esac
  76. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVE-NO-SUBSCRIPTION" --menu "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE.\n \nEnable 'pve-no-subscription' repository?" 14 58 2 \
  77. "yes" " " \
  78. "no" " " 3>&2 2>&1 1>&3)
  79. case $CHOICE in
  80. yes)
  81. msg_info "Enabling 'pve-no-subscription' repository"
  82. cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
  83. deb http://download.proxmox.com/debian/pve ${VERSION} pve-no-subscription
  84. EOF
  85. msg_ok "Enabled 'pve-no-subscription' repository"
  86. ;;
  87. no)
  88. msg_error "Selected no to Enabling 'pve-no-subscription' repository"
  89. ;;
  90. esac
  91. if [[ "${VERSION}" == "bookworm" ]]; then
  92. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription'(enabled) and 'enterprise'(disabled) repositories.\n \nAdd 'ceph package repositories?" 14 58 2 \
  93. "yes" " " \
  94. "no" " " 3>&2 2>&1 1>&3)
  95. case $CHOICE in
  96. yes)
  97. msg_info "Enabling 'ceph package repositories'"
  98. cat <<EOF >/etc/apt/sources.list.d/ceph.list
  99. # deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
  100. deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
  101. EOF
  102. msg_ok "Enabled 'ceph package repositories'"
  103. ;;
  104. no)
  105. msg_error "Selected no to Enabling 'ceph package repositories'"
  106. ;;
  107. esac
  108. fi
  109. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVETEST" --menu "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pvetest' repository?" 14 58 2 \
  110. "yes" " " \
  111. "no" " " 3>&2 2>&1 1>&3)
  112. case $CHOICE in
  113. yes)
  114. msg_info "Adding 'pvetest' repository and set disabled"
  115. cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
  116. # deb http://download.proxmox.com/debian/pve ${VERSION} pvetest
  117. EOF
  118. msg_ok "Added 'pvetest' repository"
  119. ;;
  120. no)
  121. msg_error "Selected no to Adding 'pvetest' repository"
  122. ;;
  123. esac
  124. if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then
  125. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \
  126. "yes" " " \
  127. "no" " " 3>&2 2>&1 1>&3)
  128. case $CHOICE in
  129. yes)
  130. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
  131. msg_info "Disabling subscription nag"
  132. 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
  133. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  134. msg_ok "Disabled subscription nag (Delete browser cache)"
  135. ;;
  136. no)
  137. whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
  138. msg_error "Selected no to Disabling subscription nag"
  139. ;;
  140. esac
  141. fi
  142. if ! systemctl is-active --quiet pve-ha-lrm; then
  143. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HIGH AVAILABILITY" --menu "Enable high availability?" 10 58 2 \
  144. "yes" " " \
  145. "no" " " 3>&2 2>&1 1>&3)
  146. case $CHOICE in
  147. yes)
  148. msg_info "Enabling high availability"
  149. systemctl enable -q --now pve-ha-lrm
  150. systemctl enable -q --now pve-ha-crm
  151. systemctl enable -q --now corosync
  152. msg_ok "Enabled high availability"
  153. ;;
  154. no)
  155. msg_error "Selected no to Enabling high availability"
  156. ;;
  157. esac
  158. fi
  159. if systemctl is-active --quiet pve-ha-lrm; then
  160. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HIGH AVAILABILITY" --menu "If you plan to utilize a single node instead of a clustered environment, you can disable unnecessary high availability (HA) services, thus reclaiming system resources.\n\nIf HA becomes necessary at a later stage, the services can be re-enabled.\n\nDisable high availability?" 18 58 2 \
  161. "yes" " " \
  162. "no" " " 3>&2 2>&1 1>&3)
  163. case $CHOICE in
  164. yes)
  165. msg_info "Disabling high availability"
  166. systemctl disable -q --now pve-ha-lrm
  167. systemctl disable -q --now pve-ha-crm
  168. systemctl disable -q --now corosync
  169. msg_ok "Disabled high availability"
  170. ;;
  171. no)
  172. msg_error "Selected no to Disabling high availability"
  173. ;;
  174. esac
  175. fi
  176. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \
  177. "yes" " " \
  178. "no" " " 3>&2 2>&1 1>&3)
  179. case $CHOICE in
  180. yes)
  181. msg_info "Updating Proxmox VE (Patience)"
  182. apt-get update &>/dev/null
  183. apt-get -y dist-upgrade &>/dev/null
  184. msg_ok "Updated Proxmox VE"
  185. ;;
  186. no)
  187. msg_error "Selected no to Updating Proxmox VE"
  188. ;;
  189. esac
  190. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \
  191. "yes" " " \
  192. "no" " " 3>&2 2>&1 1>&3)
  193. case $CHOICE in
  194. yes)
  195. msg_info "Rebooting Proxmox VE"
  196. sleep 2
  197. msg_ok "Completed Post Install Routines"
  198. reboot
  199. ;;
  200. no)
  201. msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)"
  202. msg_ok "Completed Post Install Routines"
  203. ;;
  204. esac
  205. }
  206. header_info
  207. echo -e "\nThis script will Perform Post Install Routines.\n"
  208. while true; do
  209. read -p "Start the Proxmox VE Post Install Script (y/n)?" yn
  210. case $yn in
  211. [Yy]*) break ;;
  212. [Nn]*) clear; exit ;;
  213. *) echo "Please answer yes or no." ;;
  214. esac
  215. done
  216. if ! command -v pveversion >/dev/null 2>&1; then
  217. header_info
  218. msg_error "\n No PVE Detected!\n"
  219. exit
  220. fi
  221. start_routines