Uložení na CD-RW


#!/bin/bash
# Description: Script na automatizaci vypalovani zaloh
# Author: DotaZ
# Date: 2004-01-26 RC1
# Destination: for my homenet
#
# POZN:
# 2004-04-24 uprava pro jadra 2.6.x (tj pro ata burning)

ODKUD="/var/backup"
SPEED="10"
DEV="ATA:1,0,0"
PUBLISHER="Create by DotaZ"
PREPAIR="Prepair on `date`"
VOLUME="backup_`date +%Y-%m-%d`"

# ===================================================================
echo "Vypaleni zalohy na CD."
echo "Provedte zalohu, vlozte CDRW 700MB a "
echo -n "az budete pripraven stiskninete a/A [a/n] "
read pokracovat
if [ "$pokracovat" = "n" ] || [ "$pokracovat" = "N" ]; then
    echo "Nashledanou priste!"
    exit
fi

# Vymaz CD
# Kontrola pritomnosti programu cdrecord
if [ -f /usr/bin/cdrecord ]; then
	echo -n "Opravdu si prejete CD smazat? [a/n] "
	read smazat
	if [ "$smazat" = "a" ] || [ "$smazat" = "A" ]; then
		echo -n "Vlozte CD do mechaniky a stisknete enter."
		read
		echo "Mazu CD!"
		/usr/bin/cdrecord -v dev=$DEV speed=$SPEED blank=fast &>/dev/null
		echo "CD je prazdne. Smazane :-)"
	fi
else
	echo "Program cdrecord neni nainstalovan, nebo neni v /usr/bin/cdrecord!"
fi
# Vypaleni CD
# Kontrola pritomnosti programu mkisofs
if [ -f /usr/bin/mkisofs ]; then
	echo -n "Opravdu si prejete CD vypalit? [a/n] "
	read vypalit
	if [ "$vypalit" = "a" ] || [ "$vypalit" = "A" ]; then
		echo -n "Vlozte CD do mechaniky a stisknete enter."
		read
		echo
		IMG_SIZE=`/usr/bin/mkisofs -R -J -l -iso-level 2 -print-size -q $ODKUD`
		echo "Palim CD ..."
if [ "0$IMG_SIZE" -ne 0 ]; then
    /usr/bin/mkisofs -R -J -l -P "$PUBLISHER" -p "$PREPAIR" -V "$VOLUME" -iso-level 2 $ODKUD | /usr/bin/cdrecord driver=mmc_cdr driveropts=burnfree -eject fs=24m speed=$SPEED dev=$DEV tsize=${IMG_SIZE}s - &>/dev/null
#	/usr/bin/beep -f 440 -l 200 -r 2
else
	echo "CHYBA! (podteceni IMG_SIZE - nekorektni velikost image adresare)"
fi
	echo "CD vypaleno!"
	fi
else
	echo "Program mkisofs neni nainstalovan, nebo neni v /usr/bin/mkisofs!"
fi

Petr Jakubec © 2004