Bash Script to Check MD5 Checksum of DVD Content

This Bash script clears the terminal, identifies the DVD device and its mount point, and checks the MD5 checksum of the DVD content against a '.checksum.md5' file.
 avatar
unknown
sh
9 months ago
770 B
5
Indexable
#!/bin/bash
clear
FILE='.checksum.md5'
SPACE_CODE='\040'
Dash_Line(){
    printf '_%.0s' {1..80}
}
DVD_Device_Name=$(cat /proc/sys/dev/cdrom/info | grep "drive name:" | awk '{print $3}')
if [ -z "${DVD_Device_Name}" ];
then
    echo "Device not found!"
    exit 1
fi
DVD_Device=/dev/$DVD_Device_Name
echo "DEVICE    -> $DVD_Device"
Mount_Point=$(cat /proc/mounts | grep $DVD_Device | awk '{print $2}')
if [ -z "${Mount_Point}" ];
then
    echo "Disk not found!"
    exit 1
fi
while [[ $Mount_Point =~ $SPACE_CODE ]];
do
    Mount_Point="${Mount_Point/"$SPACE_CODE"/' '}"
done
echo "MOUNT     -> $Mount_Point"
Dash_Line; echo; cd "$Mount_Point"; ls -g; Dash_Line; echo; echo
if [ -f $FILE ]; then
    md5sum -c .checksum.md5
else
   echo "File '$FILE' does not exist."
fi
Editor is loading...
Leave a Comment