#!/bin/bash #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.1 #Date: 31-03-07 #System: Ubuntu/Debian GNU/Linux #Information: man cdrecord #Information: http://gentoo-wiki.com/HOWTO_Create_a_DVD:Burn #Category Thunar scripts (thunar->edit->custom actions) #Name: Burn to CD #Description: Burn a ISO image to a cdrom burner #Information: This script is device specific and will need manual editing #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/burn-cd %F #Patterns: *.iso;*.ISO #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Burn to CD" DESCRIPTION=$"Burn a ISO image to a cdrom burner" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" burn_cd() { #$1=device #$2=image #cdrecord -v -eject fs=32m driveropts=burnfree -dev=/dev/dvdrw -dao -speed= dvd.img #cdrecord -v -eject fs=32m driveropts=burnfree -dev=/dev/dvdrw -dao /mnt/hda3/feisty-alternate-i386.iso #cdrecord -v -eject fs=32m driveropts=burnfree speed=4 -dao dev=1,0,0 "$1" #echo "command: cdrecord -v -eject fs=128m driveropts=burnfree -dao $1 $2" #~ cdrecord -v -eject fs=32m driveropts=burnfree speed=2 -dao "$1" "$2" cdrecord -v -eject fs=32m driveropts=burnfree -dao "$1" "$2" } burn_dvd() { speed=$1 device=$2 name=$3 location=$4 growisofs -dvd-compat -speed=4 -Z /dev/dvd -V ENTERPRISE_S4D4 -dvd-video /mnt/hda1/ENTERPRISE/ENTERPRISE_S4D4/ growisofs -dvd-compat -speed=4 -Z /dev/sr0 -V JOCHEM_YEEHAA -dvd-video /media/sda3/downloads/usenet/JOCHEM_YEEHAA } scan_devices() { #cdrecord -scanbus #cdrecord -devices #wodim -devices device=$(wodim -devices | grep dev | sed s/\'//g | head -n 1 | awk '{print $2}') if [ ! -n "$device" ] then cecho "red" $"no burning device found!" cecho "red" $"hit the enter key to exit" read input exit fi } check_program() { #whereis $1 if [ ! -e /usr/bin/$1 ] then cecho "red" $"$1 not found, installing now" sudo apt-get install "$1" fi } check_md5sum() { echo $"generating the checksum code of the file, standby..." result=$(md5sum "$1" | cut -f 1 -d ' ') cecho "green" "checksum: $result" echo $"searching the directory for matching checksum code, standby..." dirname=${1%/*} match=$(find "$dirname/" -maxdepth 1 -type f -exec grep -H -n "$result" '{}' \;) cecho "green" $"match: $match" if [ ! -n "$match" ] then cecho "red" $"no matching md5 checksum found!" echo -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi fi } cecho "green" $"processing:" for I in "$@" do filename=${I##*/} cecho "blue" "$filename" done echo -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi cecho "blue" "---------------" for I in "$@" do cecho "green" "starting: " check_program cdrecord check_program wodim scan_devices echo -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi # step 1: check if file is iso type # step 2: check if there is a cd burning device # step 3: check if there is an empty cd # step 4: check if you have permision on the file and device # step 4: burn the disk # step 5: return the status if [ -f "$I" ] then unset correct filetype=$(file -b "$I" | cut -f 1 -d ",") [[ "$filetype" = *"ISO 9660 CD-ROM"* ]] && correct=true [[ "$filetype" = "UDF filesystem"* ]] && correct=true if [ ! -n "$correct" ] then cecho "red" $"this is not a correct disk-image" cecho "red" "filetype: $filetype" continue fi fi echo -n $"do you want to do a check md5sum scan and test [N/y]? " read input if [ "$input" = "y" ] then check_md5sum "$I" fi if [ ! -O "$I" ] then user="sudo" fi filename=${I##*/} cecho "green" $"start burning $filename" "$device" "$I" #~ $user burn_cd "$device" "$I" cecho "green" $"completed:" cecho "blue" "---------------" done echo -n $"done, closing [Y/n]? " read input if [ ! "$input" = "n" ] then exit 0 fi cecho "green" $"done, closing after 3 seconds" sleep 3 exit