From e238849069946f00f85402408c40090e5a78104c Mon Sep 17 00:00:00 2001 From: Nick Daly Date: Wed, 30 Nov 2016 11:41:41 -0600 Subject: [PATCH] Sync the ramlog back to disk, hourly. - Since the cron job could be called before the user reboots after install (or if log2ram is disabled), we check that the hdd log location exists before syncing. - Copy the log2ram.hourly sync script to cron's hourly directory on install. --- install.sh | 6 ++++-- log2ram | 3 +++ log2ram.hourly | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 log2ram.hourly diff --git a/install.sh b/install.sh index 94e7b9b..08aea60 100644 --- a/install.sh +++ b/install.sh @@ -7,8 +7,10 @@ then cp log2ram /usr/local/bin/log2ram chmod a+x /usr/local/bin/log2ram systemctl enable log2ram - + cp log2ram.hourly /etc/cron.hourly/log2ram + chmod +x /etc/cron.hourly/log2ram + echo "Reboot to activate log2ram" -else +else echo "You need to be ROOT (sudo can be used)" fi diff --git a/log2ram b/log2ram index 032962b..297d514 100644 --- a/log2ram +++ b/log2ram @@ -7,6 +7,9 @@ SIZE=40M USE_RSYNC=false sync () { + [ -d $HDD_LOG ] || echo "ERROR: $HDD_LOG doesn't exist! Can't sync." + [ -d $HDD_LOG ] || exit 1 + if [ "$USE_RSYNC" = true ]; then rsync -aXWv --delete --links $HDD_LOG $RAM_LOG 2>&1 | tee -a $LOG2RAM_LOG else diff --git a/log2ram.hourly b/log2ram.hourly new file mode 100644 index 0000000..df43424 --- /dev/null +++ b/log2ram.hourly @@ -0,0 +1,3 @@ +#! /bin/sh + +/usr/local/bin/log2ram write