From 85e021c864151aa20ede19152e25ca03cb31777e Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 20:03:53 +0100 Subject: [PATCH] =?UTF-8?q?chore=20=F0=9F=93=A6:=20Add=20setup=20scripts?= =?UTF-8?q?=20for=20`/usr/local/bin`=20and=20APT=20post-invoke=20hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit includes the installation of `pve-remove-nag.sh` script, checks for legacy `proxmoxlib.js`, and ensures that `/usr/local/bin` exists. Additionally, it sets up an APT post-invoke hook to run necessary tasks after package installations. --- tasks/subscription.yml | 106 +++++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/tasks/subscription.yml b/tasks/subscription.yml index e0441f6..6a24492 100644 --- a/tasks/subscription.yml +++ b/tasks/subscription.yml @@ -1,12 +1,81 @@ --- -- name: subscription | Ensure nag patch state directory exists +- name: Ensure /usr/local/bin exists ansible.builtin.file: - path: /var/lib/proxmox-nag-patch + path: /usr/local/bin state: directory owner: root group: root mode: "0755" +- name: subscription | Check for legacy proxmoxlib.js + ansible.builtin.stat: + path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js + register: proxmoxlib_js + +- name: Install pve-remove-nag script + ansible.builtin.copy: + 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="" + if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then + echo "Patching Mobile UI nag..." + printf "%s\n" \ + "$MARKER" \ + "" \ + "" >> "$MOBILE_TPL" + fi + when: proxmoxlib_js.stat.exists + +- name: Install APT post-invoke hook for nag removal + ansible.builtin.copy: + dest: /etc/apt/apt.conf.d/no-nag-script + owner: root + group: root + mode: "0644" + content: | + DPkg::Post-Invoke { "/usr/local/bin/pve-remove-nag.sh"; }; + ############################ # Legacy proxmoxlib.js ############################ @@ -14,16 +83,8 @@ - name: subscription | Check for legacy proxmoxlib.js ansible.builtin.stat: path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js - checksum_algorithm: sha256 register: proxmoxlib_js -- name: subscription | Read stored checksum (legacy) - ansible.builtin.slurp: - src: /var/lib/proxmox-nag-patch/proxmoxlib.js.sha256 - register: proxmoxlib_js_checksum_stored - when: proxmoxlib_js.stat.exists - failed_when: false - - name: subscription | Trigger legacy nag patch if needed ansible.builtin.meta: flush_handlers when: @@ -33,28 +94,3 @@ != (proxmoxlib_js_checksum_stored.content | b64decode | trim) notify: Ppatch legacy proxmoxlib.js -############################ -# Minified proxmoxlib.min.js (VE 8/9) -############################ - -- name: subscription | Check for minified proxmoxlib.min.js (VE 8/9) - ansible.builtin.stat: - path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js - checksum_algorithm: sha256 - register: proxmoxlib_min_js - -- name: subscription | Read stored checksum (minified) - ansible.builtin.slurp: - src: /var/lib/proxmox-nag-patch/proxmoxlib.min.js.sha256 - register: proxmoxlib_min_checksum_stored - when: proxmoxlib_min_js.stat.exists - failed_when: false - -- name: subscription | Trigger minified nag patch if needed - ansible.builtin.meta: flush_handlers - when: - - proxmoxlib_min_js.stat.exists - - proxmoxlib_min_checksum_stored.content is not defined - or proxmoxlib_min_js.stat.checksum - != (proxmoxlib_min_checksum_stored.content | b64decode | trim) - notify: Patch minified proxmoxlib.js