Skip to content

Instantly share code, notes, and snippets.

@packz
Last active December 27, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packz/7384674 to your computer and use it in GitHub Desktop.
Save packz/7384674 to your computer and use it in GitHub Desktop.
Do you backup your freepto?
ACTION=="add", SUBSYSTEM=="block", ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="xxxx", ENV{UDISKS_AUTO}="0", OWNER="packz", SYMLINK+="freepto%n", RUN+="/sbin/freepto.sh %k %n"
#!/bin/bash
#
# I don't know if it is a workaround, but I can't found a udev's rule to
# match the main device but not the partitions, so in the programm launched
# by udev (i.e. this) I check the partition number and if not empty then we
# exit from it
DEVNAME="$1"
NUM="$2"
if [ ! -z "$2" ];then exit;fi
SIZE=$(/sbin/blockdev --getsz /dev/$DEVNAME)
SIZE=$((${SIZE}*512))
DATE=$(date --iso)
BACKUP_FILE=backup-$DATE.img
DISPLAY=:0.0 su packz -c "xterm -e \"dd if=/dev/$DEVNAME | pv --size $SIZE | dd of=/2HD/${BACKUP_FILE};echo -en '\n\tcalcolo MD5\n\n';md5sum /2HD/${BACKUP_FILE} /dev/$DEVNAME;echo -n premi un tasto per chiudere;read miao\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment