Update post-pve-install.sh

This commit is contained in:
CanbiZ 2025-10-02 10:28:51 +02:00
parent e2ec7c18e2
commit ef616ac29b

View File

@ -370,7 +370,6 @@ EOF
REPO_FILE="" REPO_FILE=""
REPO_ACTIVE=0 REPO_ACTIVE=0
REPO_COMMENTED=0 REPO_COMMENTED=0
# Suche nach existierendem Block (aktiv oder auskommentiert)
for file in /etc/apt/sources.list.d/*.sources; do for file in /etc/apt/sources.list.d/*.sources; do
if grep -q "Components:.*pve-no-subscription" "$file"; then if grep -q "Components:.*pve-no-subscription" "$file"; then
REPO_FILE="$file" REPO_FILE="$file"
@ -481,24 +480,24 @@ EOF
fi fi
# ---- PVETEST ---- # ---- PVETEST ----
if component_exists_in_sources "pvetest"; then if component_exists_in_sources "pve-test"; then
msg_ok "'pvetest' repository already exists (skipped)" msg_ok "'pve-test' repository already exists (skipped)"
else else
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVETEST" \ 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 (deb822)?" 14 58 2 \ --menu "The 'pve-test' repository can give advanced users access to new features and updates before they are officially released.\n\nAdd (Disabled) 'pvetest' repository (deb822)?" 14 58 2 \
"yes" " " \ "yes" " " \
"no" " " 3>&2 2>&1 1>&3) "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in case $CHOICE in
yes) yes)
msg_info "Adding 'pvetest' repository (deb822, disabled)" msg_info "Adding 'pve-test' repository (deb822, disabled)"
cat >/etc/apt/sources.list.d/pvetest.sources <<EOF cat >/etc/apt/sources.list.d/pve-test.sources <<EOF
# Types: deb # Types: deb
# URIs: http://download.proxmox.com/debian/pve # URIs: http://download.proxmox.com/debian/pve
# Suites: trixie # Suites: trixie
# Components: pvetest # Components: pve-test
# Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg # Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF EOF
msg_ok "Added 'pvetest' repository" msg_ok "Added 'pve-test' repository"
;; ;;
no) msg_error "Selected no to Adding 'pvetest' repository" ;; no) msg_error "Selected no to Adding 'pvetest' repository" ;;
esac esac
@ -515,11 +514,62 @@ post_routines_common() {
yes) yes)
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 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
msg_info "Disabling subscription nag" msg_info "Disabling subscription nag"
encoded_script=$(base64 -w0 <<'EOF' # Create external script, this is needed because DPkg::Post-Invoke is fidly with quote interpretation
[ -s /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js ] && ! grep -q -F 'NoMoreNagging' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && echo 'Removing subscription nag from UI...' && sed -i '/data\.status/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; [ -s /usr/share/pve-yew-mobile-gui/index.html.tpl ] && sed -i '/<script id="custom-close-subscription-nag-js">.*<\/script>/d' /usr/share/pve-yew-mobile-gui/index.html.tpl && sed -i '/<\/head>/i <script id="custom-close-subscription-nag-js">document.addEventListener("DOMContentLoaded",()=>{let e=new MutationObserver(()=>{let t=document.querySelector('\''dialog.pwt-outer-dialog[aria-label="No valid subscription"]'\'');if(t){let i=t.querySelector(".fa-close");t.style.visibility="hidden",t.removeAttribute("open"),i&&i.click(),e.disconnect()}});e.observe(document.body,{childList:!0,subtree:!0})});</script>' /usr/share/pve-yew-mobile-gui/index.html.tpl mkdir -p /usr/local/bin
cat >/usr/local/bin/pve-remove-nag.sh <<'EOF'
#!/bin/sh
WEB_JS=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
if [ -s "$WEB_JS" ] && ! grep -q NoMoreNagging "$WEB_JS"; then
echo "Patching Web UI nag..."
sed -i -e "/data\.status/ s/!//" -e "/data\.status/ s/active/NoMoreNagging/" "$WEB_JS"
fi
MOBILE_TPL=/usr/share/pve-yew-mobile-gui/index.html.tpl
MARKER="<!-- MANAGED BLOCK FOR MOBILE NAG -->"
if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then
echo "Patching Mobile UI nag..."
printf "%s\n" \
"$MARKER" \
"<script>" \
" function removeSubscriptionElements() {" \
" // --- Remove subscription dialogs ---" \
" const dialogs = document.querySelectorAll('dialog.pwt-outer-dialog');" \
" dialogs.forEach(dialog => {" \
" const text = (dialog.textContent || '').toLowerCase();" \
" if (text.includes('subscription')) {" \
" dialog.remove();" \
" console.log('Removed subscription dialog');" \
" }" \
" });" \
"" \
" // --- Remove subscription cards, but keep Reboot/Shutdown/Console ---" \
" const cards = document.querySelectorAll('.pwt-card.pwt-p-2.pwt-d-flex.pwt-interactive.pwt-justify-content-center');" \
" cards.forEach(card => {" \
" const text = (card.textContent || '').toLowerCase();" \
" const hasButton = card.querySelector('button');" \
" if (!hasButton && text.includes('subscription')) {" \
" card.remove();" \
" console.log('Removed subscription card');" \
" }" \
" });" \
" }" \
"" \
" const observer = new MutationObserver(removeSubscriptionElements);" \
" observer.observe(document.body, { childList: true, subtree: true });" \
" removeSubscriptionElements();" \
" setInterval(removeSubscriptionElements, 300);" \
" setTimeout(() => {observer.disconnect();}, 10000);" \
"</script>" \
"" >> "$MOBILE_TPL"
fi
EOF EOF
) chmod 755 /usr/local/bin/pve-remove-nag.sh
echo "DPkg::Post-Invoke { \"echo $encoded_script | base64 -d | bash\"; };" > /etc/apt/apt.conf.d/no-nag-script
cat >/etc/apt/apt.conf.d/no-nag-script <<'EOF'
DPkg::Post-Invoke { "/usr/local/bin/pve-remove-nag.sh"; };
EOF
chmod 644 /etc/apt/apt.conf.d/no-nag-script
msg_ok "Disabled subscription nag (Delete browser cache)" msg_ok "Disabled subscription nag (Delete browser cache)"
;; ;;
no) no)