Merge pull request 'fix 🐛: Fix typo and add file permission in logrotate.yml task' (#7) from dev into main
Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
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
|
||||||
@@ -15,6 +15,6 @@
|
|||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
daemon_reexec: true
|
daemon_reexec: true
|
||||||
|
|
||||||
- name: logrotate reload
|
- name: Logrotate reload
|
||||||
ansible.builtin.command: logrotate /etc/logrotate.conf
|
ansible.builtin.command: logrotate /etc/logrotate.conf
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -13,98 +13,99 @@
|
|||||||
|
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Check if {{ item }} exists
|
- name: logrotate | Check if exists {{ item }}
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: logrotate_file
|
register: logrotate_file
|
||||||
|
|
||||||
- name: Configure {{ item }}
|
- name: logrotate | Configure {{ item }}
|
||||||
|
when: logrotate_file.stat.exists
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Backup {{ item }} once
|
- name: logrotate | Backup once {{ item }}
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ item }}.original"
|
dest: "{{ item }}.original"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
remote_src: true
|
remote_src: true
|
||||||
args:
|
args:
|
||||||
creates: "{{ item }}.original"
|
creates: "{{ item }}.original"
|
||||||
|
|
||||||
- name: Ensure daily rotation
|
- name: logrotate | Ensure daily rotation
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*weekly'
|
regexp: '^\s*weekly'
|
||||||
replace: 'daily'
|
replace: 'daily'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Set rotate (number of retained logs)
|
- name: logrotate | Set rotate (number of retained logs)
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^(\s*rotate\s+).*'
|
regexp: '^(\s*rotate\s+).*'
|
||||||
line: ' rotate {{ proxmox_logrotate_rotate }}'
|
line: ' rotate {{ proxmox_logrotate_rotate }}'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*daily'
|
insertafter: '^\s*daily'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure maxsize is set
|
- name: logrotate | Ensure maxsize is set
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^(\s*maxsize\s+).*'
|
regexp: '^(\s*maxsize\s+).*'
|
||||||
line: ' maxsize {{ proxmox_logrotate_maxsize }}'
|
line: ' maxsize {{ proxmox_logrotate_maxsize }}'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*rotate'
|
insertafter: '^\s*rotate'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure Compress
|
- name: logrotate | Ensure Compress
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*compress\b'
|
regexp: '^\s*compress\b'
|
||||||
line: ' compress'
|
line: ' compress'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*maxsize'
|
insertafter: '^\s*maxsize'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure delaycompress
|
- name: logrotate | Ensure delaycompress
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*delaycompress\b'
|
regexp: '^\s*delaycompress\b'
|
||||||
line: ' delaycompress'
|
line: ' delaycompress'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*compress'
|
insertafter: '^\s*compress'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
when: logrotate_file.stat.exists
|
|
||||||
|
|
||||||
|
|
||||||
# only for logrotate.conf
|
# only for logrotate.conf
|
||||||
|
|
||||||
- name: Uncomment dateext if commented
|
- name: logrotate | Uncomment dateext if commented
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*#\s*(dateext)\b'
|
regexp: '^\s*#\s*(dateext)\b'
|
||||||
replace: '\1'
|
replace: '\1'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Uncomment compress if commented
|
- name: logrotate | Uncomment compress if commented
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*#\s*(compress)\b'
|
regexp: '^\s*#\s*(compress)\b'
|
||||||
replace: '\1'
|
replace: '\1'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure missingok is present
|
- name: logrotate | Ensure missingok is present
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*missingok\b'
|
regexp: '^\s*missingok\b'
|
||||||
line: 'missingok'
|
line: 'missingok'
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure notifempty is present
|
- name: logrotate | Ensure notifempty is present
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*notifempty\b'
|
regexp: '^\s*notifempty\b'
|
||||||
line: 'notifempty'
|
line: 'notifempty'
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
- name: repos | Comment out Proxmox enterprise repo lines
|
- name: repos | Comment out Proxmox enterprise repo lines
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/apt/sources.list.d/pve-enterprise.list
|
path: /etc/apt/sources.list.d/pve-enterprise.list
|
||||||
regexp: '^(deb\s+)'
|
regexp: '^\s*deb\s+'
|
||||||
replace: '# \1'
|
replace: '# deb '
|
||||||
when: pve_enterprise_repo.stat.exists
|
when: pve_enterprise_repo.stat.exists
|
||||||
register: enterprise_changed
|
notify: Run apt update
|
||||||
|
|
||||||
# Proxmox no-subscription repo
|
# Proxmox no-subscription repo
|
||||||
|
|
||||||
@@ -31,23 +31,20 @@
|
|||||||
- name: repos | Uncomment Proxmox no-subscription repo if present
|
- name: repos | Uncomment Proxmox no-subscription repo if present
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/apt/sources.list.d/pve-install-repo.list
|
path: /etc/apt/sources.list.d/pve-install-repo.list
|
||||||
regexp: '^#\s*(deb\s+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription)'
|
regexp: '^\s*#\s*(deb\s+.*pve-no-subscription)'
|
||||||
replace: '\1'
|
replace: '\1'
|
||||||
when: pve_install_repo.stat.exists
|
when: pve_install_repo.stat.exists
|
||||||
register: no_sub_uncommented
|
notify: Run apt update
|
||||||
|
|
||||||
- name: repos | Add Proxmox no-subscription repo if missing
|
- name: repos | Add Proxmox no-subscription repo if missing
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/apt/sources.list.d/pve-install-repo.list
|
path: /etc/apt/sources.list.d/pve-install-repo.list
|
||||||
regexp: '^deb\s+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription$'
|
regexp: '^\s*deb\s+.*pve-no-subscription\s*$'
|
||||||
line: "deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription"
|
line: >-
|
||||||
|
deb http://download.proxmox.com/debian/pve
|
||||||
|
{{ ansible_distribution_release }}
|
||||||
|
pve-no-subscription
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
when: pve_install_repo.stat.exists
|
when: pve_install_repo.stat.exists
|
||||||
register: no_sub_added
|
notify: Run apt update
|
||||||
|
|
||||||
# Notify Run apt update only once if any of the above tasks changed something
|
|
||||||
notify:
|
|
||||||
- Run apt update
|
|
||||||
# Trigger only if any changes occurred
|
|
||||||
when: enterprise_changed.changed or no_sub_uncommented.changed or no_sub_added.changed
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure /usr/local/bin exists
|
- name: subscription | Ensure /usr/local/bin exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /usr/local/bin
|
path: /usr/local/bin
|
||||||
state: directory
|
state: directory
|
||||||
@@ -12,63 +12,16 @@
|
|||||||
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
|
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
|
||||||
register: proxmoxlib_js
|
register: proxmoxlib_js
|
||||||
|
|
||||||
- name: Install pve-remove-nag script
|
- name: subscription | Install pve-remove-nag script
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
|
src: pve-remove-nag.sh
|
||||||
dest: /usr/local/bin/pve-remove-nag.sh
|
dest: /usr/local/bin/pve-remove-nag.sh
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
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
|
when: proxmoxlib_js.stat.exists
|
||||||
|
|
||||||
- name: Install APT post-invoke hook for nag removal
|
- name: subscription | Install APT post-invoke hook for nag removal
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/apt/apt.conf.d/no-nag-script
|
dest: /etc/apt/apt.conf.d/no-nag-script
|
||||||
owner: root
|
owner: root
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
/var/log/pve/*.log /var/log/pve/tasks/*.log {
|
|
||||||
daily
|
|
||||||
rotate {{ proxmox_logrotate_rotate }}
|
|
||||||
compress
|
|
||||||
missingok
|
|
||||||
notifempty
|
|
||||||
maxsize {{ proxmox_logrotate_maxsize }}
|
|
||||||
create 0640 root adm
|
|
||||||
sharedscripts
|
|
||||||
postrotate
|
|
||||||
systemctl reload rsyslog >/dev/null 2>&1 || true
|
|
||||||
endscript
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user