egscripts/egrdbackup-usb/initial.sh

35 lines
No EOL
877 B
Bash
Executable file

#/bin/bash
#
# This script runs before the main rdiffbackup script
# useful for mounting USB drives
#
#
#
POSSIBLE_USB_DRIVES="/dev/sdc1 /dev/sdd1"
MOUNT_POINT="/mnt"
USB_DRIVE="nodrivefound"
#
#
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 == "nodrivefound" -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
fi
#echo $INITIAL_CMD_FILE_OK