You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

burniso 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # Burn ISO images from the command line.
  3. # see "man burniso"
  4. # Copyright (C) 2009, Michael Deelwater <michael.deelwater@googlemail.com>
  5. # Copyright (C) 2010, Joaquim Boura <x-un-i@sapo.pt>
  6. # Copyright (C) 2011-2015, Stefan Lippers-Hollmann <s.l-h@gmx.de>
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; version 2 of the
  10. # License.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. # xorriso parameters
  17. SPEED="8"
  18. FS="14M"
  19. OPTIONS="-dao -eject -v"
  20. set -e
  21. shopt -s nullglob
  22. shopt -s nocaseglob
  23. # Print out an error message and exit.
  24. error () {
  25. echo >&2 "Error: ${*}"
  26. exit 1
  27. }
  28. # Look for writeable devices.
  29. devices=$(awk '
  30. /^drive name/ {
  31. sub(/^.*:[[:space:]]*/, "")
  32. num_dev = split($0, devices)
  33. }
  34. /(write CD)|(write DVD)/ {
  35. sub(/^.*:[[:space:]]*/, "")
  36. split($0, entries)
  37. for (i = 1; i <= num_dev; ++i)
  38. if (entries[i] == 1)
  39. printf("/dev/%s\n", devices[i])
  40. }' /proc/sys/dev/cdrom/info | uniq)
  41. case $(echo ${devices} | wc -w) in
  42. 0) error "No suitable device found!"
  43. ;;
  44. 1) device=$devices
  45. ;;
  46. *) select device in $devices; do
  47. break
  48. done
  49. ;;
  50. esac
  51. # Check write permission for device.
  52. if [ ! -w "${device}" ]; then
  53. error "No write permission for ${device}!".
  54. fi
  55. printf "Using device %s.\n" "${device}"
  56. if [ -z "$(echo *.iso)" ]; then
  57. error "No ISO images in current directory!"
  58. fi
  59. printf "Choose an ISO to burn: \n"
  60. select iso in *.iso; do
  61. break
  62. done
  63. # Check if ISO exists.
  64. if ! [ -f "${iso}" ]; then
  65. error "No ISO in currect directory!"
  66. fi
  67. printf "File %s chosen.\n" "${iso}"
  68. # Look for MD5 checksum and validate if available.
  69. if [ -f "${iso}.md5" ]; then
  70. echo "MD5 checksum found. Verifying ISO..."
  71. if ! md5sum -c "${iso}.md5"; then
  72. error "Invalid MD5 checksum!"
  73. fi
  74. fi
  75. # burn baby, burn
  76. exec xorriso -as cdrecord ${OPTIONS} "dev=${device}" "fs=${FS}" "speed=${SPEED}" "${iso}"