fix 🐛: Fix typo and add file permission in logrotate.yml task #7
46
files/pve-remove-nag.sh
Normal file
46
files/pve-remove-nag.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# source: https://github.com/community-scripts/ProxmoxVE/blob/main/tools/pve/post-pve-install.sh
|
||||
# Commit c464b95
|
||||
|
||||
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..."
|
||||
cat <<'EOF' >> "$MOBILE_TPL"
|
||||
<!-- MANAGED BLOCK FOR MOBILE NAG -->
|
||||
<script>
|
||||
function removeSubscriptionElements() {
|
||||
const dialogs =
|
||||
document.querySelectorAll('dialog.pwt-outer-dialog');
|
||||
dialogs.forEach(dialog => {
|
||||
const text = (dialog.textContent || '').toLowerCase();
|
||||
if (text.includes('subscription')) dialog.remove();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(removeSubscriptionElements);
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
removeSubscriptionElements();
|
||||
setInterval(removeSubscriptionElements, 300);
|
||||
setTimeout(() => observer.disconnect(), 10000);
|
||||
</script>
|
||||
EOF
|
||||
fi
|
||||
@@ -12,60 +12,13 @@
|
||||
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
|
||||
register: proxmoxlib_js
|
||||
|
||||
- name: Install pve-remove-nag script
|
||||
- name: subscription | Install pve-remove-nag script
|
||||
ansible.builtin.copy:
|
||||
src: pve-remove-nag.sh
|
||||
dest: /usr/local/bin/pve-remove-nag.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
|
||||
content: |
|
||||
#!/bin/sh
|
||||
# source: https://github.com/community-scripts/ProxmoxVE/blob/main/tools/pve/post-pve-install.sh
|
||||
# Commit c464b95
|
||||
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
|
||||
when: proxmoxlib_js.stat.exists
|
||||
|
||||
- name: Install APT post-invoke hook for nag removal
|
||||
|
||||
Reference in New Issue
Block a user
[Lines 6-21] [Score: 4] The script hardcodes a path to the web JavaScript file and checks for its existence using
-s. This approach might fail if the file is not present or if its name changes. Consider usingfindwith appropriate filters instead.