|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: thost96 (thost96) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | + |
| 7 | +header_info() { |
| 8 | + clear |
| 9 | + cat <<"EOF" |
| 10 | + ____ __ _________ ____ __ ____ __ ____ |
| 11 | + / __ \/ |/ / ____/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / / |
| 12 | + / /_/ / /|_/ / / __ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / / |
| 13 | + / ____/ / / / /_/ / / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / / |
| 14 | +/_/ /_/ /_/\____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/ |
| 15 | + |
| 16 | +EOF |
| 17 | +} |
| 18 | + |
| 19 | +RD=$(echo "\033[01;31m") |
| 20 | +YW=$(echo "\033[33m") |
| 21 | +GN=$(echo "\033[1;92m") |
| 22 | +CL=$(echo "\033[m") |
| 23 | +BFR="\\r\\033[K" |
| 24 | +HOLD="-" |
| 25 | +CM="${GN}✓${CL}" |
| 26 | +CROSS="${RD}✗${CL}" |
| 27 | + |
| 28 | +set -euo pipefail |
| 29 | +shopt -s inherit_errexit nullglob |
| 30 | + |
| 31 | +msg_info() { |
| 32 | + local msg="$1" |
| 33 | + echo -ne " ${HOLD} ${YW}${msg}..." |
| 34 | +} |
| 35 | + |
| 36 | +msg_ok() { |
| 37 | + local msg="$1" |
| 38 | + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" |
| 39 | +} |
| 40 | + |
| 41 | +msg_error() { |
| 42 | + local msg="$1" |
| 43 | + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" |
| 44 | +} |
| 45 | + |
| 46 | +start_routines() { |
| 47 | + header_info |
| 48 | + VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" |
| 49 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PMG SOURCES" --menu "This will set the correct sources to update and install Proxmox Mail Gateway.\n \nChange to Proxmox Mail Gateway sources?" 14 58 2 \ |
| 50 | + "yes" " " \ |
| 51 | + "no" " " 3>&2 2>&1 1>&3) |
| 52 | + case $CHOICE in |
| 53 | + yes) |
| 54 | + msg_info "Changing to Proxmox Mail Gateway Sources" |
| 55 | + cat <<EOF >/etc/apt/sources.list |
| 56 | +deb http://deb.debian.org/debian ${VERSION} main contrib |
| 57 | +deb http://deb.debian.org/debian ${VERSION}-updates main contrib |
| 58 | +deb http://security.debian.org/debian-security ${VERSION}-security main contrib |
| 59 | +EOF |
| 60 | + msg_ok "Changed to Proxmox Mail Gateway Sources" |
| 61 | + ;; |
| 62 | + no) |
| 63 | + msg_error "Selected no to Correcting Proxmox Mail Gateway Sources" |
| 64 | + ;; |
| 65 | + esac |
| 66 | + |
| 67 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PMG-ENTERPRISE" --menu "The 'pmg-enterprise' repository is only available to users who have purchased a Proxmox Mail Gateway subscription.\n \nDisable 'pmg-enterprise' repository?" 14 58 2 \ |
| 68 | + "yes" " " \ |
| 69 | + "no" " " 3>&2 2>&1 1>&3) |
| 70 | + case $CHOICE in |
| 71 | + yes) |
| 72 | + msg_info "Disabling 'pmg-enterprise' repository" |
| 73 | + cat <<EOF >/etc/apt/sources.list.d/pmg-enterprise.list |
| 74 | +# deb https://enterprise.proxmox.com/debian/pmg ${VERSION} pmg-enterprise |
| 75 | +EOF |
| 76 | + msg_ok "Disabled 'pmg-enterprise' repository" |
| 77 | + ;; |
| 78 | + no) |
| 79 | + msg_error "Selected no to disabling 'pmg-enterprise' repository" |
| 80 | + ;; |
| 81 | + esac |
| 82 | + |
| 83 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PMG-NO-SUBSCRIPTION" --menu "The 'pmg-no-subscription' repository provides access to all of the open-source components of Proxmox Mail Gateway.\n \nEnable 'pmg-no-subscription' repository?" 14 58 2 \ |
| 84 | + "yes" " " \ |
| 85 | + "no" " " 3>&2 2>&1 1>&3) |
| 86 | + case $CHOICE in |
| 87 | + yes) |
| 88 | + msg_info "Enabling 'pmg-no-subscription' repository" |
| 89 | + cat <<EOF >/etc/apt/sources.list.d/pmg-install-repo.list |
| 90 | +deb http://download.proxmox.com/debian/pmg ${VERSION} pmg-no-subscription |
| 91 | +EOF |
| 92 | + msg_ok "Enabled 'pmg-no-subscription' repository" |
| 93 | + ;; |
| 94 | + no) |
| 95 | + msg_error "Selected no to enabling 'pmg-no-subscription' repository" |
| 96 | + ;; |
| 97 | + esac |
| 98 | + |
| 99 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PMG TEST" --menu "The 'pmgtest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pmgtest' repository?" 14 58 2 \ |
| 100 | + "yes" " " \ |
| 101 | + "no" " " 3>&2 2>&1 1>&3) |
| 102 | + case $CHOICE in |
| 103 | + yes) |
| 104 | + msg_info "Adding 'pmgtest' repository and set disabled" |
| 105 | + cat <<EOF >/etc/apt/sources.list.d/pmgtest-for-beta.list |
| 106 | +# deb http://download.proxmox.com/debian/pmg ${VERSION} pmgtest |
| 107 | +EOF |
| 108 | + msg_ok "Added 'pmgtest' repository" |
| 109 | + ;; |
| 110 | + no) |
| 111 | + msg_error "Selected no to adding 'pmgtest' repository" |
| 112 | + ;; |
| 113 | + esac |
| 114 | + |
| 115 | + if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then |
| 116 | + 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 \ |
| 117 | + "yes" " " \ |
| 118 | + "no" " " 3>&2 2>&1 1>&3) |
| 119 | + case $CHOICE in |
| 120 | + yes) |
| 121 | + 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 |
| 122 | + msg_info "Disabling subscription nag" |
| 123 | + 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 |
| 124 | + apt --reinstall install proxmox-widget-toolkit &>/dev/null |
| 125 | + msg_ok "Disabled subscription nag (Delete browser cache)" |
| 126 | + ;; |
| 127 | + no) |
| 128 | + 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 |
| 129 | + msg_error "Selected no to disabling subscription nag" |
| 130 | + ;; |
| 131 | + esac |
| 132 | + fi |
| 133 | + |
| 134 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox Mail Gateway now?" 11 58 2 \ |
| 135 | + "yes" " " \ |
| 136 | + "no" " " 3>&2 2>&1 1>&3) |
| 137 | + case $CHOICE in |
| 138 | + yes) |
| 139 | + msg_info "Updating Proxmox Mail Gateway (Patience)" |
| 140 | + apt-get update &>/dev/null |
| 141 | + apt-get -y dist-upgrade &>/dev/null |
| 142 | + msg_ok "Updated Proxmox Mail Gateway" |
| 143 | + ;; |
| 144 | + no) |
| 145 | + msg_error "Selected no to updating Proxmox Mail Gateway" |
| 146 | + ;; |
| 147 | + esac |
| 148 | + |
| 149 | + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox Mail Gateway now? (recommended)" 11 58 2 \ |
| 150 | + "yes" " " \ |
| 151 | + "no" " " 3>&2 2>&1 1>&3) |
| 152 | + case $CHOICE in |
| 153 | + yes) |
| 154 | + msg_info "Rebooting Proxmox Mail Gateway" |
| 155 | + sleep 2 |
| 156 | + msg_ok "Completed Post Install Routines" |
| 157 | + reboot |
| 158 | + ;; |
| 159 | + no) |
| 160 | + msg_error "Selected no to reboot Proxmox Mail Gateway (Reboot recommended)" |
| 161 | + msg_ok "Completed Post Install Routines" |
| 162 | + ;; |
| 163 | + esac |
| 164 | +} |
| 165 | + |
| 166 | +header_info |
| 167 | +echo -e "\nThis script will Perform Post Install Routines.\n" |
| 168 | +while true; do |
| 169 | + read -p "Start the Proxmox Mail Gateway Post Install Script (y/n)?" yn |
| 170 | + case $yn in |
| 171 | + [Yy]*) break ;; |
| 172 | + [Nn]*) clear; exit ;; |
| 173 | + *) echo "Please answer yes or no." ;; |
| 174 | + esac |
| 175 | +done |
| 176 | + |
| 177 | +start_routines |
0 commit comments