media-sucker/scripts/reader.sh

45 lines
795 B
Bash
Executable File

#! /bin/sh
. $(dirname $0)/common.sh
with_time_dir () {
mtype=$1; shift
now=$(date --rfc-3339=s | tr ' ' T)
dir="$mtype/$now"
mkdir -p "$dir"
cd "$dir"
setenv time "$now"
setenv mtype "$mtype"
setenv directory "$dir"
setenv status "reading"
echo "$mtype" > $OUTDIR/status.reader
if ! "$@"; then
log "$1 failed"
setenv status "read failed"
else
log "$1 succeeded"
setenv status "read finished"
eject
fi
}
while sleep 2; do
echo "idle" > $OUTDIR/status.reader
case $(setcd -i) in
*"Disc found in drive: audio"*)
log "Found audio disc"
( with_time_dir audio /scripts/cd.audio.read.sh )
;;
*"Disc found in drive: data"*)
log "Found DVD"
( with_time_dir video /scripts/dvd.video.read.sh )
;;
*)
;;
esac
done
# vi: sw=2 ts=2 et ai