diff --git a/packages/bsp/common/usr/lib/armbian/armbian-common b/packages/bsp/common/usr/lib/armbian/armbian-common index 91c439a43d..db49b27b04 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-common +++ b/packages/bsp/common/usr/lib/armbian/armbian-common @@ -12,7 +12,7 @@ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin my_name="${0##*/}" -Log=/var/log/armbian-services.log +Log=/var/log/armbian-hardware-monitor.log show_motd_warning() { cat > /etc/update-motd.d/90-warning < "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}" diff --git a/packages/bsp/common/usr/lib/armbian/armbian-ramlog b/packages/bsp/common/usr/lib/armbian/armbian-ramlog index 7a9fac179d..b3a69cb3fc 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-ramlog +++ b/packages/bsp/common/usr/lib/armbian/armbian-ramlog @@ -6,8 +6,8 @@ # License version 2. This program is licensed "as is" without any # warranty of any kind, whether express or implied. -SIZE=40M -USE_RSYNC=false +SIZE=50M +USE_RSYNC=true ENABLED=false [ -f /etc/default/armbian-ramlog ] && . /etc/default/armbian-ramlog @@ -27,7 +27,7 @@ isSafe () { } RecreateLogs (){ - # in case of crash those services doesn't start if there are no dirs & logs + # in case of crash those services don't start if there are no dirs & logs check_if_installed apache2 && [ ! -d /var/log/apache2 ] && mkdir -p /var/log/apache2 check_if_installed proftpd-basic && [ ! -d /var/log/proftpd ] && \ (mkdir -p /var/log/proftpd ; touch /var/log/proftpd/controls.log) @@ -39,6 +39,8 @@ RecreateLogs (){ syncToDisk () { isSafe + echo -e "\n\n$(date): Syncing logs to storage\n" | $LOG_OUTPUT + if [ "$USE_RSYNC" = true ]; then rsync -aXWv --exclude armbian-ramlog.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT else @@ -49,6 +51,8 @@ syncToDisk () { syncFromDisk () { isSafe + echo -e "\n\n$(date): Loading logs from storage\n" | $LOG_OUTPUT + if [ "$USE_RSYNC" = true ]; then rsync -aXWv --delete --exclude armbian-ramlog.log --exclude *.gz --exclude='*.[0-9]' --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT else @@ -71,8 +75,13 @@ case "$1" in [ -d $HDD_LOG ] || mkdir -p $HDD_LOG mount --bind $RAM_LOG $HDD_LOG mount --make-private $HDD_LOG - rm -f $LOG2RAM_LOG - # zram type + # preserve log and add logrotate rule + if [ ! -f $LOG2RAM_LOG ]; then + [ -f "/etc/logrotate.d/${0##*/}" ] || \ + echo -e "${LOG2RAM_LOG} {\n rotate 1\n monthly\n compress\n missingok\n notifempty\n}" \ + > "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}" + fi + # Check whether zram device is available or we need to use tmpfs if [ "$(blkid -s TYPE /dev/zram0 | awk ' { print $2 } ' | grep ext4)" ]; then mount /dev/zram0 $RAM_LOG | $LOG_OUTPUT else @@ -90,7 +99,7 @@ case "$1" in syncToDisk ;; *) - echo "Usage: log2ram {start|stop|write}" >&2 + echo "Usage: ${0##*/} {start|stop|write}" >&2 exit 1 ;; esac diff --git a/packages/bsp/common/usr/lib/armbian/armbian-zram-config b/packages/bsp/common/usr/lib/armbian/armbian-zram-config index 2bb7cbdb72..c750a6d3d0 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-zram-config +++ b/packages/bsp/common/usr/lib/armbian/armbian-zram-config @@ -42,7 +42,7 @@ activate_zram() { mkswap /dev/zram${i} swapon -p 5 /dev/zram${i} done - echo -e "\n### Activated ${zram_devices} zram swap devices with ${mem_per_zram_device} MB each\n" >>${Log} + echo -e "\n### Activated ${zram_devices} zram swap devices with $(( ${mem_per_zram_device} / 1048576 )) MB each\n" >>${Log} # Dedicate SIZE MB (uncompressed) /dev/zram0 device for log2ram and choose most efficient # compression scheme available -- https://patchwork.kernel.org/patch/9918897/ @@ -58,7 +58,7 @@ activate_zram() { fi mkfs.ext4 -O ^has_journal -s 1024 -L log2ram /dev/zram0 - read algo >${Log} } # activate_zram