From 54d1d59ff81eec5d7ad98bb5eff8cde7cf2494e0 Mon Sep 17 00:00:00 2001 From: Stefan Mertl Date: Thu, 1 Feb 2018 17:46:39 +0100 Subject: [PATCH] A script to compress and copy the current ruwai log file to the SD card. The script should be started regularly by a cron job --- software/bash/copy_current_ruwai_log.bash | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 software/bash/copy_current_ruwai_log.bash diff --git a/software/bash/copy_current_ruwai_log.bash b/software/bash/copy_current_ruwai_log.bash new file mode 100644 index 0000000..8f63cb9 --- /dev/null +++ b/software/bash/copy_current_ruwai_log.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "Checking for the ruwai_sd block device." +if [ -b /dev/disk/by-label/ruwai_sd ] +then + echo "Ruwai SD card block device found." +else + echo "ERROR: The SD card block device was not found. The SD card seems not to be inserted in the slot. Exiting." + exit 1 +fi + +# Check for the mounted SD card using the mount command. +echo "Checking the correct mounting of the SD card using the mount command." +if mount | grep -q "/dev/mmcblk[01]p1 on /media/sd" +then + echo "The SD card is correctly mounted." +else + echo "The SD card is not mounted." + exit 1 +fi + +# Check for the existing log directory. +if [ ! -d /media/sd/log ]; then + mkdir /media/sd/log + chown ruwai:adm /media/sd/log +fi +echo "Copying the current log files." +gzip -c /var/log/ruwai.log > /home/ruwai/tmp/ruwai_current.log.gz +mv /home/ruwai/tmp/ruwai_current.log.gz /media/sd/log + -- 2.11.4.GIT