ปรับปรุงเครื่องคัดลอกแผ่นซีดี
Submitted by wd on Tue, 2007-01-30 19:37
ปรับปรุงครั้งที่ 1
- แก้ปัญหาแผ่นธรรมดาอ่านผิดพลาด ด้วยการพยายามแยกแผ่น
- ถ้าเป็นตระกูล VCD ซึ่งเป็น multitrack ใช้ readcd+cdrecord -clone
- แต่ถ้าเป็นพวก mp3 ธรรมดา ใช้ dd+cdrecord แบบ normal
- เนื่องจากทดสอบด้วย debian-desktop (etch) เลยต้องเพิ่มฟังก์ชั่นการยกเลิกการเมาต์อัตโนมัติด้วย
- ฝากทดสอบและช่วยปรับปรุงให้ด้วยครับ
# vi d.inittab-cpcd
#!/bin/bash # THIS IS THE CD COPIER PROGRAM # - REQUIRE PACKAGE: setcd eject cdrecord(wodim) # - PUT THE LINE # D1:2345:once:/root/d.inittab-cpcd # IN /etc/inittab THEN REBOOT # - PUT THESE 2 FILES IN /root # - RUN AS ROOT #if [ $USER != "ROOT" ]; then # su #fi DEV=/dev/hdb # SOURCE DRIVE TMP=/tmp/x.bin # TEMP IMAGE FILE SPEED=8 # WRITE SPEED MNT="/mnt/tmp" # TEMP MOUNT DIR beep() { echo -e "\a" } beeperror() { for i in `seq 1 6`; do beep; sleep .15; done } check_disk_type() { # RETURN 1=CLONE 2=NORMAL while mount | grep "$DEV "; do umount $DEV >> /dev/null; sleep 1; done if setcd -i $DEV | grep 'Disc found in drive: audio disc' >> /dev/null; then return 1; fi if ! [ -d $MNT ]; then mkdir $MNT; fi if mount | grep "$MNT "; then umount $MNT >> /dev/null; fi mount $DEV $MNT VAR=`ls $MNT | tr '[A-Z]' '[a-z]'` VAR=`echo $VAR | grep vcd | grep mpeg | grep segment | grep ext` while mount | grep "$DEV "; do umount $DEV >> /dev/null; sleep 1; done if [ "$VAR" == "" ]; then return 2; fi return 1 } wait_read_close() { # MAX RETRY LOOP = 100 for (( i=0; i<=100; i++ )) do umount $DEV if setcd -i $DEV | grep open >> /dev/null; then # SLEEP 3 SECONDS beep; sleep 3 else check_disk_type ISCLONE=$? if [ $ISCLONE -eq 1 ]; then readcd -clone dev=$DEV f=$TMP else dd if=$DEV of=$TMP fi return $ISCLONE fi done eject -t $1 /sbin/shutdown -h now return } # BEGIN MAIN rm -rf $TMP #CHECK 1ST CDR IS ORIGINAL CD THEN DUP. TO /tmp while ! [ -s $TMP ] do eject $DEV beep wait_read_close $DEV done ISCLONE=$? # CALL MULTIPLE INSTANCE TO DESTINATION DRIVES #d.func.cpcd DEVICE SPEED ISOFILE #KERNEL-2.6 /root/d.func-cpcd /dev/hdb $ISCLONE $SPEED $TMP & /root/d.func-cpcd /dev/hdc $ISCLONE $SPEED $TMP & /root/d.func-cpcd /dev/hdd $ISCLONE $SPEED $TMP & wait /sbin/shutdown -h now
# vi d.func-cpcd
#!/bin/bash # THIS IS THE CD COPIER PROGRAM # - REQUIRE PACKAGE: setcd eject cdrecord(wodim) # - PUT THE LINE # D1:2345:once:/root/d.inittab-cpcd # IN /etc/inittab THEN REBOOT # - PUT THESE 2 FILES IN /root # - RUN AS ROOT DEV=$1 ISCLONE=$2 SPEED=$3 TMP=$4 beep() { echo -e "\a" } beepwrite() { beep; sleep .15; beep } beeperror() { for i in `seq 1 6`; do beep; sleep .15; done } wait_write_close() { # MAX RETRY LOOP = 100 for (( i=0; i<=100; i++ )) do # WAIT FOR INSERT DISC if setcd -i $DEV | grep 'is open' >> /dev/null; then beepwrite; sleep 3 # IF NO DISC INSERTED THEN BREAK elif setcd -i $DEV | grep 'No disc' >> /dev/null; then exit 1 else while mount | grep "$DEV "; do umount $DEV >> /dev/null; sleep 1; done if [ $ISCLONE -eq 1 ]; then cdrecord -clone gracetime=2 -raw96r dev=$DEV speed=$SPEED driveropts=burnfree -overburn -multi -xa1 -eject $TMP else cdrecord gracetime=2 dev=$DEV speed=$SPEED driveropts=burnfree -overburn -eject $TMP fi # LAST CHECK WRITING if setcd -i $DEV | grep 'error' >> /dev/null; then beeperror; sleep 3 exit 1 else eject $DEV return fi fi done #END PROG eject -t $1 exit 1 } if [ ! $1 ] && [ ! $2 ] && [ ! $3 ] && [ ! $4 ] ; then echo " USAGE : $0 DRIVE ISCLONE(1=CLONE,2=NORMAL) SPEED TEMP-IMG" echo " EXAM1 : $0 /dev/hdb 1 4 /tmp/x.bin" exit 1 fi #CHECK IMAGE FILE if ! [ -f $TMP ] ; then echo " Image file $TMP does not existed" exit 1 fi #COPY TO NEW BLANK CD while [ -f $TMP ] do eject $DEV wait_write_close beepwrite done
- Printer-friendly version
- Log in or register to post comments
- 3920 reads
Recent comments