#!/bin/bash # Wait for a device on the USB to settle, then mount it, sync it, and unmount it debug=0 [ "$debug" -gt "0" ] && logger -t Tolino "Started by udev" [ "$ID_FS_LABEL" = "tolino" ] || exit 0 [ "$debug" -gt "0" ] && logger -t Tolino "It's a Tolino :)" [ "$DEVPATH" = "${DEVPATH/block}" ] && exit 0 [ "$debug" -gt "0" ] && logger -t Tolino "It's a block device" [ "$ACTION" = "change" ] || exit 0 [ "$debug" -gt "0" ] && logger -t Tolino "It's remounting" [ -n "$DISK_MEDIA_CHANGE" ] && exit 0 ( logger -t Tolino "I have found device $DEVNAME and I am mounting it on /mnt" mount $DEVNAME /mnt [ "$debug" -eq "0" ] && books=`rsync -vac /home/me/eBooks/ /mnt/Books/` [ "$debug" -gt "0" ] && books=`rsync -Pvac /home/me/eBooks/ /mnt/Books/` [ "$debug" -gt "0" ] && echo "$books" >>/tmp/tolino.rsync.txt umount /mnt logger -t Tolino "I mounted device $DEVNAME, synced the books to it, and unmounted it again" echo -e "$books\n\nTolino has been updated and can be unplugged." | mail -s "Tolino update" me ) &