#!/bin/rc
# Sit and watch the CD-ROM drive and rip any audio CDs that are
# inserted. Depends on having cdprep in the path.
# Usage: cdripper [bitrate]
if (! ~ $#* 1) {
echo usage: cdripper bitrate
exit usage
}
if (ps | grep cdfs) {
echo 'Detected cdfs, killing and restarting'
slay cdfs | rc
}
cdfs
if (! test -e "/tmp/cdtracks") {
mkdir /tmp/cdtracks
}
haveripped = 0
while (~ 1 1) {
if (! ~ `{ls /mnt/cd | wc | awk '{print $1}'} 1) {
if (~ $haveripped 0) {
cp /mnt/cd/ctl /tmp/cdinfo
for (i in `{ls /mnt/cd/a*}) {
cp $i /tmp/cdtracks/
}
sed 1q /tmp/cdinfo | rc > /tmp/cddbinfo
cdprep $1 /tmp/cddbinfo
}
haveripped = 1
}
if (~ `{ls /mnt/cd | wc | awk '{print $1}'} 1) {
haveripped = 0
}
sleep 5
}
g1
|