Crear imagen ISO
Nombre: mkiso
Autor: Luis Moreno Rodriguez
Lenguaje: Bash
Licencia: GPL
Dependencias: mkisofs
Script que crea una imagen ISO a partir de los ficheros y carpetas que se le pasen como parámetros. También crea un fichero de texto en la raíz de la ISO que sirve como índice del contenido.
mkiso archivo1 directorio directorio2 archivo2 ...
#!/bin/bash
# AUTOR: Luis Moreno Rodriguez 2010
function mkiso () {
if [ $# = 0 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo -e "Make an iso image from files and folders. Usage 'mkiso file1 folder folder2 file2...'."
return
fi
for i in $*; do
if [ ! -f "$i" ] && [ ! -d "$i" ]; then echo "'$i' is not valid file or folder"
return
fi
done
if [ $# -gt 1 ]; then
local ISO=$HOME/makeisofile_$$.iso
local TMP_DIR=/tmp/deleteme_makeiso_$$
mkdir $TMP_DIR
echo -n "Copying all files in temporal directory... "
for i in $*; do
cp -rf $i $TMP_DIR
done
echo "done"
else
local TMP_DIR=$1
if [ -d "$TMP_DIR" ]; then
TMP_DIR=${TMP_DIR%/} # delete de last character if it is '/'
fi
local ISO=$HOME/$TMP_DIR.iso
fi
if [ -d $TMP_DIR ]; then
local CONTENTSFILE=contents
echo -n "Creating table of contents... "
ls -lRF $TMP_DIR > $TMP_DIR/$CONTENTSFILE
echo "done"
fi
echo "Creating ISO9660 image file in $ISO... "
mkisofs -r -o $ISO $TMP_DIR
if [ $# -gt 1 ]; then
rm -rf $TMP_DIR
else
if [ -d $TMP_DIR ]; then
rm $TMP_DIR/$CONTENTSFILE
fi
fi
echo "Saved ISO image in '$ISO'"
}
mkiso $*