|« Bug bitten ankle day 2, the horror continues||Climate change bites back? »|
Now that hard drives are so cheap I decided to copy a whole stack of archival DVD's onto a hard drive. I wanted to use a shell script because the copy was running on a machine that didn't have a monitor or keyboard attached. The idea was to feed it DVD's every time the drawer popped open until the stack was done.
Step 1 was to add a HAL callout to run a script whenever the DVD was inserted. I create a file called 31-dvdinsert.fdi in /usr/share/hal/fdi/information/20thirdparty/ which is where these things go in Centos or Redhat 5 systems. The name isn't that important but the extension .fdi is. Forget the .fdi and it won't work. On this particular system the DVD drive resides at /dev/hdc, using ls -l /dev/cdrom will show you where it is on your system. The contents of the file were:
Next I created a shell script in /usr/libexec called dvdinsert
The purpose of this script is to call another script to do the actual copying. HAL callouts can only run for a very short time before they are terminated. This script passes the Volume name of the DVD inserted to dvdinsert1 which is run as a detached process. THe contents of dvdinsert1 are shown below.
This script does the actual copying of the files to a subdirectory found that it creates in /mnt/backup where an external usb drive is mounted. It also puts some messages in /var/log/messages so that you can keep track of the copy progress. You will need to create the /media/dvd mountpoint so the DVD can be mounted by the script. If you know a better way to do this feel free to leave a comment.