clonecd 750 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. usage () {
  3. cat <<EOF>&2
  4. Usage: ${0##*/} [OPTIONS] ISOFILE
  5. Dump optical disc to ISOFILE (without extension).
  6. Options:
  7. -h: Show this help.
  8. -d DRIVE: Set optical drive to use (e.g. 'sr1').
  9. EOF
  10. }
  11. DRIVE=/dev/sr0
  12. while getopts ":hd:" opt; do
  13. case $opt in
  14. h)
  15. usage
  16. exit ;;
  17. d)
  18. DRIVE=/dev/$OPTARG ;;
  19. \?)
  20. usage
  21. exit 1 ;;
  22. esac
  23. done
  24. shift $((OPTIND - 1))
  25. if [ $# -eq 0 ]; then
  26. usage
  27. exit 1
  28. fi
  29. if ! command -v readcd >/dev/null 2>&1; then
  30. echo >&2 "'readcd' not found"
  31. exit 1
  32. fi
  33. ## Fast?
  34. readcd dev="$DRIVE" f="$1.iso" -v retries=5 timeout=30 -noerror
  35. ## Slow
  36. # readcd f="$1.iso" -v retries=32 timeout=30 -s speed=16 -noerror
  37. # dd if=$DRIVE of='$1.iso' bs=2048 count=$(isosize -d 2048 $DRIVE) conv=sync,notrunc