46 lines
1.3 KiB
Text
Executable file
46 lines
1.3 KiB
Text
Executable file
#/bin/bash
|
|
#
|
|
# This script runs before the main rdiffbackup script
|
|
# useful for mounting USB drives
|
|
#
|
|
#
|
|
#
|
|
POSSIBLE_USB_DRIVES="/dev/sdc1 /dev/sdd1 /dev/sde1"
|
|
MOUNT_POINT="/mnt"
|
|
USB_DRIVE="unknowndrive"
|
|
#
|
|
#
|
|
for i in $POSSIBLE_USB_DRIVES
|
|
do
|
|
if udevinfo --query=name --name $i > /dev/null 2>> $LOGFILE
|
|
then
|
|
USB_DRIVE=$i
|
|
fi
|
|
done
|
|
if [ $USB_DRIVE == "unknowndrive" -o $MOUNT_POINT"xxx" == "xxx" ]
|
|
then
|
|
echo "ERROR - Mount point or drive device not defined in config file or drive device not found" >> $LOGFILE 2>> $LOGFILE
|
|
INITIAL_CMD_FILE_OK="false"
|
|
elif ! mount | grep $USB_DRIVE > /dev/null
|
|
then
|
|
if ! mount $USB_DRIVE $MOUNT_POINT
|
|
then
|
|
echo "ERROR - Couldn't mount USB Drive" >> $LOGFILE 2>> $LOGFILE
|
|
INITIAL_CMD_FILE_OK="false"
|
|
fi
|
|
else
|
|
echo "WARNING - $USB_DRIVE already mounted" >> $LOGFILE 2>> $LOGFILE
|
|
INITIAL_CMD_FILE_OK="false"
|
|
fi
|
|
|
|
# Check whether a fsck is needed after the backup
|
|
# Get the current date in seconds from the 1/1/1970
|
|
CUR_DATE=`$DATE_COMMAND +%s`
|
|
DATE_STRING=$($TUNE2FS_COMMAND -l $USB_DRIVE |grep "Next check after:")
|
|
CHECK_DATE_STRING=$(echo $DATE_STRING | awk 'BEGIN {FS=":"}{print $2":"$3":"$4}')
|
|
CHECK_DATE=$($DATE_COMMAND --date="$CHECK_DATE_STRING" +%s)
|
|
if [ $CUR_DATE -ge $CHECK_DATE ] ; then
|
|
FS_CHECK=true
|
|
else
|
|
FS_CHECK=false
|
|
fi
|