#!/bin/bash # Mount the backup partition DEV #+ and execute all *.active scripts in the SCRIPTDIR directory MOUNTPOINT="/tmp/backup_partition" DEV="/dev/mapper/data-backup" SCRIPTDIR="$MOUNTPOINT/scripts" ERR_NOSCRIPT=2 ERRS= [ -d $MOUNTPOINT ] || mkdir $MOUNTPOINT echo "Mounting '${DEV}' at '${MOUNTPOINT}'" mount $DEV $MOUNTPOINT [ ! -d $SCRIPTDIR ] && exit $ERR_NOSCRIPT for s in $SCRIPTDIR/*.active do if [ -x $s ]; then printf "Executing ${s}:" source $s retval="$?" if [ $retval == 0 ]; then printf " [ OK ] \n" else printf " [ Error:${retval} ] \n" ERRS="${ERRS} ${s}" fi fi done echo "Unmounting '${DEV}'" umount $DEV