From a98b087c5d84f4db726b8606da1f5fa328c11d2b Mon Sep 17 00:00:00 2001 From: MacRimi Date: Wed, 13 Aug 2025 15:55:22 +0200 Subject: [PATCH] Update log2RAM --- scripts/post_install/auto_post_install.sh | 22 ++++++++++---- .../post_install/customizable_post_install.sh | 30 ++++++++++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/scripts/post_install/auto_post_install.sh b/scripts/post_install/auto_post_install.sh index e1fa9a2..804f6e5 100644 --- a/scripts/post_install/auto_post_install.sh +++ b/scripts/post_install/auto_post_install.sh @@ -686,11 +686,18 @@ install_log2ram_auto() { sed -i "s/^SIZE=.*/SIZE=$LOG2RAM_SIZE/" /etc/log2ram.conf - - + LOG2RAM_BIN="$(command -v log2ram || echo /usr/local/bin/log2ram)" + rm -f /etc/cron.daily/log2ram /etc/cron.weekly/log2ram /etc/cron.monthly/log2ram 2>/dev/null || true rm -f /etc/cron.hourly/log2ram - echo "0 */$CRON_HOURS * * * root /usr/sbin/log2ram write" > /etc/cron.d/log2ram - msg_ok "$(translate "log2ram write scheduled every") $CRON_HOURS $(translate "hour(s)")" + + { + echo 'MAILTO=""' + echo "0 */$CRON_HOURS * * * root $LOG2RAM_BIN write >/dev/null 2>&1" + } > /etc/cron.d/log2ram + + chmod 0644 /etc/cron.d/log2ram + chown root:root /etc/cron.d/log2ram + msg_ok "$(translate "Log2RAM write scheduled every") $CRON_HOURS $(translate "hour(s)")" cat << 'EOF' > /usr/local/bin/log2ram-check.sh @@ -706,7 +713,12 @@ fi EOF chmod +x /usr/local/bin/log2ram-check.sh - echo "*/5 * * * * root /usr/local/bin/log2ram-check.sh" > /etc/cron.d/log2ram-auto-sync + { + echo 'MAILTO=""' + echo "*/5 * * * * root /usr/local/bin/log2ram-check.sh >/dev/null 2>&1" + } > /etc/cron.d/log2ram-auto-sync + chmod 0644 /etc/cron.d/log2ram-auto-sync + chown root:root /etc/cron.d/log2ram-auto-sync msg_ok "$(translate "Auto-sync enabled when /var/log exceeds 90% of") $LOG2RAM_SIZE" register_tool "log2ram" true diff --git a/scripts/post_install/customizable_post_install.sh b/scripts/post_install/customizable_post_install.sh index 1ce83fb..2422679 100644 --- a/scripts/post_install/customizable_post_install.sh +++ b/scripts/post_install/customizable_post_install.sh @@ -3002,18 +3002,18 @@ configure_log2ram() { "12" "$(translate "Every 12 hours")" OFF \ 3>&1 1>&2 2>&3) || return 0 - # Activar auto-sync si se pasa del 90% + if whiptail --title "Log2RAM" --yesno "$(translate "Enable auto-sync if /var/log exceeds 90% of its size?")" 10 60; then ENABLE_AUTOSYNC=true else ENABLE_AUTOSYNC=false fi - # Instalación + msg_info "$(translate "Installing Log2RAM from GitHub...")" rm -rf /tmp/log2ram - # Ensure git is available + if ! command -v git >/dev/null 2>&1; then msg_info "$(translate "Installing required package: git")" apt-get update -qq >/dev/null 2>&1 @@ -3031,13 +3031,22 @@ configure_log2ram() { return 1 fi - # Aplicar configuración + sed -i "s/^SIZE=.*/SIZE=$LOG2RAM_SIZE/" /etc/log2ram.conf + LOG2RAM_BIN="$(command -v log2ram || echo /usr/local/bin/log2ram)" + rm -f /etc/cron.daily/log2ram /etc/cron.weekly/log2ram /etc/cron.monthly/log2ram 2>/dev/null || true rm -f /etc/cron.hourly/log2ram - echo "0 */$CRON_HOURS * * * root /usr/sbin/log2ram write" > /etc/cron.d/log2ram + + { + echo 'MAILTO=""' + echo "0 */$CRON_HOURS * * * root $LOG2RAM_BIN write >/dev/null 2>&1" + } > /etc/cron.d/log2ram + + chmod 0644 /etc/cron.d/log2ram + chown root:root /etc/cron.d/log2ram msg_ok "$(translate "Log2RAM write scheduled every") $CRON_HOURS $(translate "hour(s)")" - # Auto-sync + if [[ "$ENABLE_AUTOSYNC" == true ]]; then cat << 'EOF' > /usr/local/bin/log2ram-check.sh #!/bin/bash @@ -3050,7 +3059,14 @@ if (( USED_KB > THRESHOLD )); then fi EOF chmod +x /usr/local/bin/log2ram-check.sh - echo "*/5 * * * * root /usr/local/bin/log2ram-check.sh" > /etc/cron.d/log2ram-auto-sync + + { + echo 'MAILTO=""' + echo "*/5 * * * * root /usr/local/bin/log2ram-check.sh >/dev/null 2>&1" + } > /etc/cron.d/log2ram-auto-sync + chmod 0644 /etc/cron.d/log2ram-auto-sync + chown root:root /etc/cron.d/log2ram-auto-sync + msg_ok "$(translate "Auto-sync enabled when /var/log exceeds 90% of") $LOG2RAM_SIZE" else rm -f /usr/local/bin/log2ram-check.sh /etc/cron.d/log2ram-auto-sync