post-pve-install.sh 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. 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 \
  42. "yes" " " \
  43. "no" " " 3>&2 2>&1 1>&3)
  44. case $CHOICE in
  45. yes)
  46. msg_info "Correcting Proxmox VE Sources"
  47. cat <<EOF >/etc/apt/sources.list
  48. deb http://ftp.debian.org/debian ${VERSION} main contrib
  49. deb http://ftp.debian.org/debian ${VERSION}-updates main contrib
  50. deb http://security.debian.org/debian-security ${VERSION}-security main contrib
  51. EOF
  52. msg_ok "Corrected Proxmox VE Sources"
  53. ;;
  54. no)
  55. msg_error "Selected no to Correcting Proxmox VE Sources"
  56. ;;
  57. esac
  58. 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 \
  59. "yes" " " \
  60. "no" " " 3>&2 2>&1 1>&3)
  61. case $CHOICE in
  62. yes)
  63. msg_info "Disabling 'pve-enterprise' repository"
  64. cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list
  65. # deb https://enterprise.proxmox.com/debian/pve ${VERSION} pve-enterprise
  66. EOF
  67. msg_ok "Disabled 'pve-enterprise' repository"
  68. ;;
  69. no)
  70. msg_error "Selected no to Disabling 'pve-enterprise' repository"
  71. ;;
  72. esac
  73. 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 \
  74. "yes" " " \
  75. "no" " " 3>&2 2>&1 1>&3)
  76. case $CHOICE in
  77. yes)
  78. msg_info "Enabling 'pve-no-subscription' repository"
  79. cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list
  80. deb http://download.proxmox.com/debian/pve ${VERSION} pve-no-subscription
  81. EOF
  82. msg_ok "Enabled 'pve-no-subscription' repository"
  83. ;;
  84. no)
  85. msg_error "Selected no to Enabling 'pve-no-subscription' repository"
  86. ;;
  87. esac
  88. if [[ "${VERSION}" == "bookworm" ]]; then
  89. 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 \nCorrect 'ceph package sources?" 14 58 2 \
  90. "yes" " " \
  91. "no" " " 3>&2 2>&1 1>&3)
  92. case $CHOICE in
  93. yes)
  94. msg_info "Enabling 'ceph package repositories'"
  95. cat <<EOF >/etc/apt/sources.list.d/ceph.list
  96. # deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise
  97. deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
  98. EOF
  99. msg_ok "Enabled 'ceph package repositories'"
  100. ;;
  101. no)
  102. msg_error "Selected no to Enabling 'ceph package repositories'"
  103. ;;
  104. esac
  105. fi
  106. 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 \
  107. "yes" " " \
  108. "no" " " 3>&2 2>&1 1>&3)
  109. case $CHOICE in
  110. yes)
  111. msg_info "Adding 'pvetest' repository and set disabled"
  112. cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list
  113. # deb http://download.proxmox.com/debian/pve ${VERSION} pvetest
  114. EOF
  115. msg_ok "Added 'pvetest' repository"
  116. ;;
  117. no)
  118. msg_error "Selected no to Adding 'pvetest' repository"
  119. ;;
  120. esac
  121. if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then
  122. 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 \
  123. "yes" " " \
  124. "no" " " 3>&2 2>&1 1>&3)
  125. case $CHOICE in
  126. yes)
  127. 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
  128. msg_info "Disabling subscription nag"
  129. 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
  130. apt --reinstall install proxmox-widget-toolkit &>/dev/null
  131. msg_ok "Disabled subscription nag (Delete browser cache)"
  132. ;;
  133. no)
  134. 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
  135. msg_error "Selected no to Disabling subscription nag"
  136. ;;
  137. esac
  138. fi
  139. if ! systemctl is-active --quiet pve-ha-lrm; then
  140. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HIGH AVAILABILITY" --menu "Enable high availability?" 10 58 2 \
  141. "yes" " " \
  142. "no" " " 3>&2 2>&1 1>&3)
  143. case $CHOICE in
  144. yes)
  145. msg_info "Enabling high availability"
  146. systemctl enable -q --now pve-ha-lrm
  147. systemctl enable -q --now pve-ha-crm
  148. systemctl enable -q --now corosync
  149. msg_ok "Enabled high availability"
  150. ;;
  151. no)
  152. msg_error "Selected no to Enabling high availability"
  153. ;;
  154. esac
  155. fi
  156. if systemctl is-active --quiet pve-ha-lrm; then
  157. 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 \
  158. "yes" " " \
  159. "no" " " 3>&2 2>&1 1>&3)
  160. case $CHOICE in
  161. yes)
  162. msg_info "Disabling high availability"
  163. systemctl disable -q --now pve-ha-lrm
  164. systemctl disable -q --now pve-ha-crm
  165. systemctl disable -q --now corosync
  166. msg_ok "Disabled high availability"
  167. ;;
  168. no)
  169. msg_error "Selected no to Disabling high availability"
  170. ;;
  171. esac
  172. fi
  173. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \
  174. "yes" " " \
  175. "no" " " 3>&2 2>&1 1>&3)
  176. case $CHOICE in
  177. yes)
  178. msg_info "Updating Proxmox VE (Patience)"
  179. apt-get update &>/dev/null
  180. apt-get -y dist-upgrade &>/dev/null
  181. msg_ok "Updated Proxmox VE"
  182. ;;
  183. no)
  184. msg_error "Selected no to Updating Proxmox VE"
  185. ;;
  186. esac
  187. CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \
  188. "yes" " " \
  189. "no" " " 3>&2 2>&1 1>&3)
  190. case $CHOICE in
  191. yes)
  192. msg_info "Rebooting Proxmox VE"
  193. sleep 2
  194. msg_ok "Completed Post Install Routines"
  195. reboot
  196. ;;
  197. no)
  198. msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)"
  199. msg_ok "Completed Post Install Routines"
  200. ;;
  201. esac
  202. }
  203. header_info
  204. echo -e "\nThis script will Perform Post Install Routines.\n"
  205. while true; do
  206. read -p "Start the Proxmox VE Post Install Script (y/n)?" yn
  207. case $yn in
  208. [Yy]*) break ;;
  209. [Nn]*) clear; exit ;;
  210. *) echo "Please answer yes or no." ;;
  211. esac
  212. done
  213. if ! command -v pveversion >/dev/null 2>&1; then
  214. header_info
  215. msg_error "\n No PVE Detected!\n"
  216. exit
  217. fi
  218. start_routines