copyCd.sh (copy local cd to nfs share)

NFS_SERVER="192.168.0.1:/music"
NFS_MOUNT="/tmp/music"
 
# cdrom
CDROM_DEVICE="/dev/hda"
CDROM_MOUNT="/tmp/cdrom"
 
 
#
# NFS
#
# share
if [ ! -d "$NFS_MOUNT" ]; then
        # create
        echo "create $NFS_MOUNT..."
        mkdir "$NFS_MOUNT" 
 
        # mount
        echo "mount $NFS_SERVER..."
        mount "$NFS_SERVER" "$NFS_MOUNT" 
fi
 
 
#
# CDROM
#
# device
if [ ! -b "$CDROM_DEVICE" ]; then
        # create 
        echo "create $CDROM_DEVICE..."
        mknod "$CDROM_DEVICE" b 3 0 
 
	# disable dma mode
	echo "disable dma..."
	hdparm -d 0 "$CDROM_DEVICE"
 
	# set max speed
	echo "set max speed for cdrom..."
	hdparm -E 52 $CDROM_DEViICE
fi
 
# mountpoint
if [ ! -d "$CDROM_MOUNT" ]; then
        # create
        echo "create $CDROM_MOUNT..."
        mkdir "$CDROM_MOUNT" 
fi
 
# mount  
echo "mount cd..."
mount -t iso9660 -o ro "$CDROM_DEVICE" "$CDROM_MOUNT"
 
 
#
# VOLUME LABEL
#
# read 
VOLUME_LABEL="$(dd if=/dev/hdd bs=1 skip=32808 count=32 2> /dev/null | tr -d " ")"
 
# replace "___" to "_-_"
VOLUME_LABEL=${VOLUME_LABEL//___/_-_}
 
# replace "_" to " "
VOLUME_LABEL=${VOLUME_LABEL//_/ }
 
 
#
# COPY
#
echo "copy $VOLUME_LABEL..."
cp -R "$CDROM_MOUNT" "$NFS_MOUNT/$VOLUME_LABEL" 
 
 
#
# UMOUNT
#
echo "umount cd..."
umount "$CDROM_MOUNT"
 
 
#
# EJECT
#
echo "eject cd..."
eject -r "$CDROM_DEVICE"