aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-11-23 12:34:32 -0200
committerSilvio Rhatto <rhatto@riseup.net>2014-11-23 12:34:32 -0200
commit092ef396af69c15d44e8456c915b4d29e5070b2e (patch)
tree54b4ee16d5718b8b3d7b5d60d1a0c10c8214edd7
parente1eb0dbc3fd07223c2992cc4e31015b9e961ae04 (diff)
downloadutils-cdrecord-092ef396af69c15d44e8456c915b4d29e5070b2e.tar.gz
utils-cdrecord-092ef396af69c15d44e8456c915b4d29e5070b2e.tar.bz2
Adding mass-ripper
-rwxr-xr-xmass-ripper69
1 files changed, 69 insertions, 0 deletions
diff --git a/mass-ripper b/mass-ripper
new file mode 100755
index 0000000..781380c
--- /dev/null
+++ b/mass-ripper
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# mass-ripper: sequentially copy CDs and DVDs.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+DRIVE="$1"
+ITERATION="1"
+INFO="0"
+MOUNT="/media/cdrom"
+
+# Disk drive
+if [ -z "$DRIVE" ]; then
+ DRIVE="/dev/sr0"
+fi
+
+# Set sudo config
+if [ "`whoami`" != 'root' ]; then
+ sudo="sudo"
+fi
+
+# Greeter
+echo "Mass CD/DVD copier, press Ctrl-C to abort..."
+
+# Thanks http://askubuntu.com/questions/197662/how-do-i-auto-copy-cd-contents-on-insertion
+while true; do
+ # Print just once per disk
+ if [ "$INFO" == "0" ]; then
+ echo "Waiting for disk #$ITERATION..."
+ fi
+
+ # Check if media is available
+ #HAS_MEDIA=$(grep $DRIVE /proc/self/mounts)
+ HAS_MEDIA=$(udisks --show-info $DRIVE | grep "has media" | cut -d : -f 2 | sed -e 's/ //g')
+
+ # If it doesn't exist, loop until it does with 1 second pause
+ if [ "$HAS_MEDIA" == "0" ]; then
+ #echo -ne "."
+ INFO="1"
+ sleep 1
+ else
+ echo "Got it! Mounting..."
+ mkdir -p cdrom || exit 1
+ $sudo mount $DRIVE $MOUNT || exit 1
+ #mkdir -p $ITERATION || exit 1
+
+ echo "Copying data..."
+ cp -vr $MOUNT $ITERATION || exit 1
+
+ echo "Fixing permissions..."
+ find $ITERATION/ -type d -exec chmod 755 {} \;
+ find $ITERATION/ -type f -exec chmod 644 {} \;
+
+ echo "Umounting..."
+ $sudo umount $MOUNT
+
+ # Eject the CD with suitable pauses to avoid any buffer problems
+ echo "Ejecting media..."
+ sleep 1
+ eject $DRIVE
+ sleep 2
+
+ # Increase counter
+ let ITERATION++
+ INFO="0"
+ fi
+ # Still looping! Go back and wait for another CD!
+done