cd_backup

Backing up a CD is a pain. Hence, this.

#!/bin/bash
device="/dev/cdrom"
test -z "$1" || device="$1"
disc_id="$(cd-discid $device | cut -d ' ' -f 1)"
if [[ -z "$disc_id" ]]; then
        echo "Could not grab Disc ID"
        exit 1
fi
if [[ ! -e "${disc_id}.wav" ]]; then
        cdparanoia -d $device 1- ${disc_id}.wav
fi
if [[ ! -e "${disc_id}.toc" ]]; then
        yes 1 | cdrdao read-toc --device $device --with-cddb ${disc_id}.toc
fi
if [[ ! -e "${disc_id}.cue" ]]; then
        cueconvert -i toc -o cue ${disc_id}.toc ${disc_id}.cue
fi