Casi todo lo he deducido de otros scripts de gentoo y alguna instalacion con sh de por ahi.
Salud3!
#!/bin/sh
# Basicamente es grabar dvds a partir de estos dos comandos :
# mkisofs -joliet-long -allow-lowercase -allow-multidot -volid DATADVD -o datadvd.iso dvd
# cdrecord -v -dao -dummy speed=4 dev=/dev/cdroms/cdrom0 datadvd.iso
#
# Usalo bajo tu resposabilidad etc, etc...
#
# Exits :
# 0, Todo OK
# 1, iso existente y no queremos borrarlo
# 2, parametro desconocido
#
VERSION="Alpha"
MKI_NOM_LARGOS="-joliet-long"
MKI_NOM_MINUS="-allow-lowercase"
MKI_NOM_VARIOS_PUNTOS="-allow-multidot"
MKI_VOLID="DATADVD"
MKI_ISO="$HOME/datadvd.iso"
MKI_DIR_DATOS="$HOME/dvd"
DEV_GRABADORA="/dev/dvdrw"
NUM_COPIAS=1
SOLO_PROBAR="-dummy"
VELOCIDAD="4"
BORRAR_ISO="N"
ABRIR_BANDEJA="N"
WIZARD="ASK"
TIPO_COPIA=0
fncHelp () {
echo "Moz Grabame un DVD please v.$VERSION"
echo "Realizado por moz667 at gmail dot com"
echo "Gracias infinitas a todo la finka linux"
echo ""
echo "Modo de uso :"
echo " moz-graba-dvds.sh [-h] [-t Numero] [Parametros extra]"
echo ""
echo "1) Parametros basicos"
echo " --help, -h : Imprime esta ayuda"
echo " --tipo Numero, -t Numero: tipo de grabacion"
echo " 1 : DVD para casi todos los reproductores de DIVX"
echo " 2 : DVD backup (nombres largos, minusculas, espacios, etc...)"
echo ""
echo " N : Proximamente... (DVD Pelicula, DVD copy, DVD PS2... lo que vaya copiando)"
echo ""
echo "2) Parametros extra"
echo " --no-joilet-long, -njl : NO permite nombres largos (joilet)"
echo " --no-allow-lowercase, -nal : NO permitir minusculas"
echo " --no-allow-multidot, -nam : NO permitir varios puntos en los nombres"
echo " --max-iso9660-filenames, -mif : OBLIGAR compatibilidad de nombres iso9660 esto siginifica que omite los tres anteriores"
echo " --volid Nombre, -vi Nombre : etiqueta del dvd. [$MKI_VOLID]"
echo " --iso-name Nombre, -in Nombre : nombre de la imagen a generar. [$MKI_ISO]"
echo " --data-dir Directorio, -dd Directorio : nombre del directorio con datos. [$MKI_DIR_DATOS]"
echo " --dev-writer Dispositivo, -dw Dispositivo : nombre del dispositivo grabador. [$DEV_GRABADORA]"
echo " --num-copys Numero, -nc Numero : numero de copias a hacer con la imagen. [$NUM_COPIAS]"
echo " --no-dummy, -nd : NO probar (hasta que no este bastante probado el script por defecto solo prueba"
echo " --speed Numero, -s Numero : Velocidad de grabacion. [$VELOCIDAD]"
echo " --rm-iso, -rs : Borrar imagen despues de la grabacion. [No]"
echo " --eject, -e : Abrir bandeja de la grabadora automaticamente. [No]"
echo " --wizard, -w : Iniciar el asistente automaticamente. [Pregunta si lo deseamos iniciar]"
echo " --no-wizard, -nw : No iniciar el asistente automaticamente ni preguntar. [Pregunta si lo deseamos iniciar]"
echo ""
exit 0
}
fncTipoCopia() {
case "$TIPO_COPIA" in
1)
MKI_NOM_LARGOS="-max-iso9660-filenames"
MKI_NOM_MINUS=""
MKI_NOM_VARIOS_PUNTOS=""
;;
2)
MKI_NOM_LARGOS="-joliet-long"
MKI_NOM_MINUS="-allow-lowercase"
MKI_NOM_VARIOS_PUNTOS="-allow-multidot"
;;
*)
;;
esac
}
# Lectura de parametros :
while true
do
case "$1" in
-h | --help)
fncHelp
exit 0
;;
--tipo | -t)
TIPO_COPIA=${2:-.}
shift 2
fncTipoCopia
;;
--no-joilet-long | -njl)
MKI_NOM_LARGOS=""
shift
;;
--no-allow-lowercase | -nal)
MKI_NOM_MINUS=""
shift
;;
--no-allow-multidot | -nam)
MKI_NOM_VARIOS_PUNTOS=""
shift
;;
--max-iso9660-filenames | -mif)
MKI_NOM_LARGOS="-max-iso9660-filenames"
MKI_NOM_MINUS=""
MKI_NOM_VARIOS_PUNTOS=""
shift
;;
--no-dummy | -nd)
SOLO_PROBAR=""
shift
;;
--rm-iso | -rs)
BORRAR_ISO="Y"
shift
;;
--eject | -e)
ABRIR_BANDEJA="Y"
shift
;;
--wizard | -w)
WIZARD="AUTO"
shift
;;
--no-wizard | -nw)
WIZARD="NO"
shift
;;
--volid | -vi)
MKI_VOLID=${2:-.}
shift 2
;;
--iso-name | -in)
MKI_ISO=${2:-.}
shift 2
;;
--data-dir | -dd)
MKI_DIR_DATOS=${2:-.}
shift 2
;;
--dev-writer | -dw)
DEV_GRABADORA=${2:-.}
shift 2
;;
--num-copys | -nc)
NUM_COPIAS=${2:-.}
shift 2
;;
--speed | -s)
VELOCIDAD=${2:-.}
shift 2
;;
-*)
echo "Parametro desconocido : $1"
echo ""
fncHelp
exit 2
;;
*)
break ;;
esac
done
if test x"$WIZARD" = xASK; then
echo "Iniciar el asistente de copia [Y/n] : "
read yn
echo ""
elif test x"$WIZARD" = xNO; then
yn="N"
else
yn="Y"
fi
if test x"$yn" = x -o x"$yn" = xy -o x"$yn" = xY; then
# maravilloso wizard :
echo "Iniciando maravilloso asistente..."
echo ""
echo "Permitir nombres largos (joilet) [Y/n] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
MKI_NOM_LARGOS=""
else
# para evitar problemas con el max-iso9660
MKI_NOM_LARGOS="-joliet-long"
MKI_NOM_MINUS="-allow-lowercase"
MKI_NOM_VARIOS_PUNTOS="-allow-multidot"
fi
echo "Permitir minusculas [Y/n] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
MKI_NOM_MINUS=""
fi
echo "Permitir varios puntos en los nombres de los ficheros [Y/n] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
MKI_NOM_VARIOS_PUNTOS=""
fi
if test x"$MKI_NOM_MINUS" = x -a x"$MKI_NOM_LARGOS" = x -a x"$MKI_NOM_VARIOS_PUNTOS" = x; then
MKI_NOM_LARGOS="-max-iso9660-filenames"
echo "Permitir nombres largos (iso9660) [Y/n] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
MKI_NOM_LARGOS=""
fi
fi
echo "Etiqueta del volumen [$MKI_VOLID] : "
read yn
if test x"$yn" != x; then
MKI_VOLID="$yn"
fi
echo "Nombre del archivo de imagen [$MKI_ISO] : "
read yn
if test x"$yn" != x; then
MKI_ISO="$yn"
fi
echo "Directorio donde se encuentran los datos para grabar [$MKI_DIR_DATOS] : "
read yn
if test x"$yn" != x; then
MKI_DIR_DATOS="$yn"
fi
echo "Dispositivo de grabacion [$DEV_GRABADORA] : "
read yn
if test x"$yn" != x; then
DEV_GRABADORA="$yn"
fi
echo "Velocidad de grabacion [$VELOCIDAD] : "
read yn
if test x"$yn" != x; then
VELOCIDAD="$yn"
fi
echo "Numero de copias [$NUM_COPIAS] : "
read yn
if test x"$yn" != x; then
NUM_COPIAS="$yn"
fi
echo "Borrar imagen al finalizar la grabacion [y/N] : "
read yn
if test x"$yn" = xy -o x"$yn" = xY; then
BORRAR_ISO="Y"
fi
echo "Abrir la bandeja de la grabadora automaticamente [y/N] : "
read yn
if test x"$yn" = xy -o x"$yn" = xY; then
ABRIR_BANDEJA="Y"
fi
fi
if test x"$SOLO_PROBAR" = x-dummy; then
echo "Solo probar (recomendable si no se ha probado antes el script) [Y/n] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
SOLO_PROBAR=""
fi
fi
if test -e $MKI_ISO; then
echo "El archivo de imagen '$MKI_ISO' ya existe, desea borrarlo [y/N] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
echo "Desea no generar un nuevo iso y utilizar el existente '$MKI_ISO' [y/N] : "
read yn
if test x"$yn" = xn -o x"$yn" = xN; then
echo "No se puede continuar con el proceso de grabacion."
echo "Mueva el archivo '$MKI_ISO' o seleccione otro nombre utilizando el asistente."
exit 1;
fi
else
rm $MKI_ISO
fi
fi
if test -e $MKI_ISO; then
echo "No se generara un nuevo archivo iso, utilizando el existente '$MKI_ISO'"
else
echo "Generando iso..."
echo "Usando : mkisofs $MKI_NOM_LARGOS $MKI_NOM_MINUS $MKI_NOM_VARIOS_PUNTOS -volid $MKI_VOLID -o $MKI_ISO $MKI_DIR_DATOS"
mkisofs $MKI_NOM_LARGOS $MKI_NOM_MINUS $MKI_NOM_VARIOS_PUNTOS -volid $MKI_VOLID -o $MKI_ISO $MKI_DIR_DATOS
fi
i=1
while [ "$i" -le "$NUM_COPIAS" ]
do
if test x"$ABRIR_BANDEJA" = xY; then
eject $DEV_GRABADORA
fi
echo "Mete el dvd virgen en la grabadora y pulsa Intro"
read yn
echo "Grabando copia [$i de $NUM_COPIAS]..."
echo "Usando : cdrecord -v -dao speed=$VELOCIDAD $SOLO_PROBAR dev=$DEV_GRABADORA $MKI_ISO"
cdrecord -v -dao speed=$VELOCIDAD $SOLO_PROBAR dev=$DEV_GRABADORA $MKI_ISO
i=$(( $i + 1 ))
done
if test x"$BORRAR_ISO" = xY; then
rm $MKI_ISO
fi
if test x"$ABRIR_BANDEJA" = xY; then
eject $DEV_GRABADORA
fi
echo ""
echo "Proceso finalizado!!!"
echo "Esperamos que haya sido de su agrado!!!"
echo ""