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
|
||||
@@ -15,6 +15,6 @@
|
||||
ansible.builtin.systemd_service:
|
||||
daemon_reexec: true
|
||||
|
||||
- name: logrotate reload
|
||||
- name: Logrotate reload
|
||||
ansible.builtin.command: logrotate /etc/logrotate.conf
|
||||
changed_when: false
|
||||
|
||||
@@ -13,98 +13,99 @@
|
||||
|
||||
block:
|
||||
|
||||
- name: Check if {{ item }} exists
|
||||
- name: logrotate | Check if exists {{ item }}
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
register: logrotate_file
|
||||
|
||||
- name: Configure {{ item }}
|
||||
- name: logrotate | Configure {{ item }}
|
||||
when: logrotate_file.stat.exists
|
||||
block:
|
||||
|
||||
- name: Backup {{ item }} once
|
||||
- name: logrotate | Backup once {{ item }}
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ item }}.original"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
remote_src: true
|
||||
args:
|
||||
creates: "{{ item }}.original"
|
||||
|
||||
- name: Ensure daily rotation
|
||||
- name: logrotate | Ensure daily rotation
|
||||
ansible.builtin.replace:
|
||||
path: "{{ item }}"
|
||||
regexp: '^\s*weekly'
|
||||
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:
|
||||
path: "{{ item }}"
|
||||
regexp: '^(\s*rotate\s+).*'
|
||||
line: ' rotate {{ proxmox_logrotate_rotate }}'
|
||||
state: present
|
||||
insertafter: '^\s*daily'
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Ensure maxsize is set
|
||||
- name: logrotate | Ensure maxsize is set
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ item }}"
|
||||
regexp: '^(\s*maxsize\s+).*'
|
||||
line: ' maxsize {{ proxmox_logrotate_maxsize }}'
|
||||
state: present
|
||||
insertafter: '^\s*rotate'
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Ensure Compress
|
||||
- name: logrotate | Ensure Compress
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ item }}"
|
||||
regexp: '^\s*compress\b'
|
||||
line: ' compress'
|
||||
state: present
|
||||
insertafter: '^\s*maxsize'
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Ensure delaycompress
|
||||
- name: logrotate | Ensure delaycompress
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ item }}"
|
||||
regexp: '^\s*delaycompress\b'
|
||||
line: ' delaycompress'
|
||||
state: present
|
||||
insertafter: '^\s*compress'
|
||||
notify: logrotate reload
|
||||
|
||||
when: logrotate_file.stat.exists
|
||||
|
||||
notify: Logrotate reload
|
||||
|
||||
# only for logrotate.conf
|
||||
|
||||
- name: Uncomment dateext if commented
|
||||
- name: logrotate | Uncomment dateext if commented
|
||||
ansible.builtin.replace:
|
||||
path: /etc/logrotate.conf
|
||||
regexp: '^\s*#\s*(dateext)\b'
|
||||
replace: '\1'
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Uncomment compress if commented
|
||||
- name: logrotate | Uncomment compress if commented
|
||||
ansible.builtin.replace:
|
||||
path: /etc/logrotate.conf
|
||||
regexp: '^\s*#\s*(compress)\b'
|
||||
replace: '\1'
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Ensure missingok is present
|
||||
- name: logrotate | Ensure missingok is present
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/logrotate.conf
|
||||
regexp: '^\s*missingok\b'
|
||||
line: 'missingok'
|
||||
state: present
|
||||
insertafter: EOF
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
- name: Ensure notifempty is present
|
||||
- name: logrotate | Ensure notifempty is present
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/logrotate.conf
|
||||
regexp: '^\s*notifempty\b'
|
||||
line: 'notifempty'
|
||||
state: present
|
||||
insertafter: EOF
|
||||
notify: logrotate reload
|
||||
notify: Logrotate reload
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
- name: repos | Comment out Proxmox enterprise repo lines
|
||||
ansible.builtin.replace:
|
||||
path: /etc/apt/sources.list.d/pve-enterprise.list
|
||||
regexp: '^(deb\s+)'
|
||||
replace: '# \1'
|
||||
regexp: '^\s*deb\s+'
|
||||
replace: '# deb '
|
||||
when: pve_enterprise_repo.stat.exists
|
||||
register: enterprise_changed
|
||||
notify: Run apt update
|
||||
|
||||
# Proxmox no-subscription repo
|
||||
|
||||
@@ -31,23 +31,20 @@
|
||||
- name: repos | Uncomment Proxmox no-subscription repo if present
|
||||
ansible.builtin.replace:
|
||||
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'
|
||||
when: pve_install_repo.stat.exists
|
||||
register: no_sub_uncommented
|
||||
notify: Run apt update
|
||||
|
||||
- name: repos | Add Proxmox no-subscription repo if missing
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/apt/sources.list.d/pve-install-repo.list
|
||||
regexp: '^deb\s+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription$'
|
||||
line: "deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} 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
|
||||
state: present
|
||||
insertafter: EOF
|
||||
when: pve_install_repo.stat.exists
|
||||
register: no_sub_added
|
||||
|
||||
# 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
|
||||
notify: Run apt update
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: Ensure /usr/local/bin exists
|
||||
- name: subscription | Ensure /usr/local/bin exists
|
||||
ansible.builtin.file:
|
||||
path: /usr/local/bin
|
||||
state: directory
|
||||
@@ -12,63 +12,16 @@
|
||||
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
|
||||
- name: subscription | Install APT post-invoke hook for nag removal
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/apt/apt.conf.d/no-nag-script
|
||||
owner: root
|
||||
|
gitea-actions
commented
[Lines 1-27] [Score: 3] The naming convention is inconsistent, using a mix of regular and descriptive task names. This might create confusion about the purpose of each task at a glance. [Lines 1-27] [Score: 3] The naming convention is inconsistent, using a mix of regular and descriptive task names. This might create confusion about the purpose of each task at a glance.
|
||||
|
||||
@@ -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
[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.