post-pve-install.sh 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 --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 --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 --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 --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 --title "CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories.\n \nEnable '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 --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 --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 --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 --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 --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 \
  144. "yes" " " \
  145. "no" " " 3>&2 2>&1 1>&3)
  146. case $CHOICE in
  147. yes)
  148. msg_info "Disabling high availability"
  149. systemctl stop pve-ha-lrm
  150. systemctl disable pve-ha-lrm &>/dev/null
  151. systemctl stop pve-ha-crm
  152. systemctl disable pve-ha-crm &>/dev/null
  153. systemctl stop corosync
  154. systemctl disable corosync &>/dev/null
  155. msg_ok "Disabled high availability"
  156. ;;
  157. no)
  158. msg_error "Selected no to Disabling high availability"
  159. ;;
  160. esac
  161. fi
  162. CHOICE=$(whiptail --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \
  163. "yes" " " \
  164. "no" " " 3>&2 2>&1 1>&3)
  165. case $CHOICE in
  166. yes)
  167. msg_info "Updating Proxmox VE (Patience)"
  168. apt-get update &>/dev/null
  169. apt-get -y dist-upgrade &>/dev/null
  170. msg_ok "Updated Proxmox VE"
  171. ;;
  172. no)
  173. msg_error "Selected no to Updating Proxmox VE"
  174. ;;
  175. esac
  176. CHOICE=$(whiptail --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \
  177. "yes" " " \
  178. "no" " " 3>&2 2>&1 1>&3)
  179. case $CHOICE in
  180. yes)
  181. msg_info "Rebooting Proxmox VE"
  182. sleep 2
  183. msg_ok "Completed Post Install Routines"
  184. reboot
  185. ;;
  186. no)
  187. msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)"
  188. msg_ok "Completed Post Install Routines"
  189. ;;
  190. esac
  191. }
  192. header_info
  193. echo -e "\nThis script will Perform Post Install Routines.\n"
  194. while true; do
  195. read -p "Start the Proxmox VE Post Install Script (y/n)?" yn
  196. case $yn in
  197. [Yy]*) break ;;
  198. [Nn]*) clear; exit ;;
  199. *) echo "Please answer yes or no." ;;
  200. esac
  201. done
  202. if ! command -v pveversion >/dev/null 2>&1; then
  203. header_info
  204. msg_error "\n No PVE Detected!\n"
  205. exit
  206. fi
  207. start_routines