media-sucker/scripts/reader.sh

37 lines
611 B
Bash
Raw Normal View History

2022-01-06 12:31:30 -07:00
#! /bin/sh
. /scripts/common.sh
with_time_dir () {
mtype=$1; shift
now=$(date --rfc-3339=s | tr ' ' T)
mkdir -p $mtype/$now
cd $mtype/$now
2022-01-06 17:33:25 -07:00
status "reader" "$mtype"
2022-01-06 12:31:30 -07:00
if ! "$@"; then
log "$1 failed"
else
log "$1 succeeded"
touch read.finished
eject
fi
}
while sleep 2; do
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
2022-01-06 17:33:25 -07:00
status "reader" "idle"
2022-01-06 12:31:30 -07:00
done
# vi: sw=2 ts=2 et ai