#!/bin/sh -e
# gmkrs02 : Copyright (C) 2007 Osamu Aoki <osamu@debian.org>, Public Domain
#set -x
error_exit()
{
echo "$1" >&2
exit 1
}
# Initialize variables
DATA_ISO="$HOME/Desktop/iso-$$.img"
LABEL=$(date +%Y%m%d-%H%M%S-%Z)
if [ $# != 0 ] && [ -d "$1" ]; then
DATA_SRC="$1"
else
# Select directory for creating ISO image from folder on desktop
DATA_SRC=$(zenity --file-selection --directory \
--title="Select the directory tree root to create ISO image") \
|| error_exit "Exit on directory selection"
fi
# Check size of archive
xterm -T "Check size $DATA_SRC" -e du -s $DATA_SRC/*
SIZE=$(($(du -s $DATA_SRC | awk '{print $1}')/1024))
if [ $SIZE -le 520 ] ; then
zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \
--text="The data size is good for CD backup:\\n $SIZE MB"
elif [ $SIZE -le 3500 ]; then
zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \
--text="The data size is good for DVD backup :\\n $SIZE MB"
else
zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \
--text="The data size is too big to backup : $SIZE MB"
error_exit "The data size is too big to backup :\\n $SIZE MB"
fi
# only xterm is sure to have working -e option
# Create raw ISO image
rm -f "$DATA_ISO" || true
xterm -T "genisoimage $DATA_ISO" \
-e genisoimage -r -J -V "$LABEL" -o "$DATA_ISO" "$DATA_SRC"
# Create RS02 supplemental redundancy
xterm -T "dvdisaster $DATA_ISO" -e dvdisaster -i "$DATA_ISO" -mRS02 -c
zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \
--text="ISO/RS02 data ($SIZE MB) \\n created at: $DATA_ISO"
# EOF
syntax highlighted by Code2HTML, v. 0.9.1