media-sucker/scripts/reader.sh

45 lines
762 B
Bash
Raw Normal View History

2022-01-06 12:31:30 -07:00
#! /bin/sh
2022-01-09 16:26:12 -07:00
. $(dirname $0)/common.sh
2022-01-06 12:31:30 -07:00
with_time_dir () {
mtype=$1; shift
now=$(date --rfc-3339=s | tr ' ' T)
2022-01-09 16:26:12 -07:00
dir="$mtype/$now"
mkdir -p "$dir"
cd "$dir"
setenv time "$now"
setenv mtype "$mtype"
setenv directory "$dir"
2022-01-09 19:50:31 -07:00
setenv status "reading"
2022-01-09 16:26:12 -07:00
tatusreader "$mtype"
2022-01-06 12:31:30 -07:00
if ! "$@"; then
log "$1 failed"
2022-01-09 19:50:31 -07:00
setenv status "read failed"
2022-01-06 12:31:30 -07:00
else
log "$1 succeeded"
2022-01-09 16:26:12 -07:00
setenv status "read finished"
2022-01-06 12:31:30 -07:00
eject
fi
}
while sleep 2; do
status reader idle
2022-01-06 12:31:30 -07:00
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